mirror of
https://github.com/ksherlock/dot_clean.git
synced 2024-06-08 15:29:28 +00:00
fixes
This commit is contained in:
parent
da54c738ae
commit
61a0229512
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
LINK.o = $(LINK.cc)
|
LINK.o = $(LINK.cc)
|
||||||
CXXFLAGS += -std=c++11
|
CXXFLAGS += -std=c++11 -g
|
||||||
|
|
||||||
dot_clean: dot_clean.o mapped_file.o
|
dot_clean: dot_clean.o mapped_file.o
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -105,7 +106,7 @@ void one_file(const std::string &data, const std::string &rsrc) noexcept try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (header->magicNum != APPLEDOUBLE_CIGAM || header->versionNum != 0x00020000)
|
if (header->magicNum != APPLEDOUBLE_MAGIC || header->versionNum != 0x00020000)
|
||||||
throw_not_apple_double();
|
throw_not_apple_double();
|
||||||
|
|
||||||
if (header->numEntries * sizeof(ASEntry) + sizeof(ASHeader) > mf.size()) throw_eof();
|
if (header->numEntries * sizeof(ASEntry) + sizeof(ASHeader) > mf.size()) throw_eof();
|
||||||
|
@ -154,7 +155,8 @@ void one_file(const std::string &data, const std::string &rsrc) noexcept try {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_FINDERINFO: {
|
case AS_FINDERINFO: {
|
||||||
if (e.entryLength != 32) {
|
/* Apple now includes xattr w/ finder info */
|
||||||
|
if (e.entryLength < 32) {
|
||||||
fputs("Warning: Invalid Finder Info size.\n", stderr);
|
fputs("Warning: Invalid Finder Info size.\n", stderr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +165,7 @@ void one_file(const std::string &data, const std::string &rsrc) noexcept try {
|
||||||
if (rfd < 0) throw_errno("com.apple.ResourceFork");
|
if (rfd < 0) throw_errno("com.apple.ResourceFork");
|
||||||
defer close_fd([rfd](){ close(rfd); });
|
defer close_fd([rfd](){ close(rfd); });
|
||||||
|
|
||||||
ssize_t ok = write(rfd, mf.data() + e.entryOffset, e.entryLength);
|
ssize_t ok = write(rfd, mf.data() + e.entryOffset, 32);
|
||||||
if (ok < 0) throw_errno("com.apple.FinderInfo");
|
if (ok < 0) throw_errno("com.apple.FinderInfo");
|
||||||
//if (ok != e.entryLength) return -1;
|
//if (ok != e.entryLength) return -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -214,15 +216,18 @@ void one_dir(std::string dir) noexcept {
|
||||||
|
|
||||||
|
|
||||||
dirp = opendir(dir.c_str());
|
dirp = opendir(dir.c_str());
|
||||||
|
if (dirp) {
|
||||||
|
while ( (dp = readdir(dirp)) ) {
|
||||||
|
if (dp->d_name[0] != '.') continue;
|
||||||
|
if (dp->d_name[1] != '_') continue;
|
||||||
|
|
||||||
while ( (dp = readdir(dirp)) ) {
|
std::string name = dp->d_name;
|
||||||
if (dp->d_name[0] != '.') continue;
|
one_file(dir + name.substr(2), dir + name);
|
||||||
if (dp->d_name[1] != '_') continue;
|
}
|
||||||
|
closedir(dirp);
|
||||||
std::string name = dp->d_name;
|
} else {
|
||||||
one_file(dir + name.substr(2), dir + name);
|
warn("%s", dir.c_str());
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,4 +281,4 @@ int main(int argc, char **argv) {
|
||||||
for (int i = 0; i < argc; ++i) one_dir(argv[i]);
|
for (int i = 0; i < argc; ++i) one_dir(argv[i]);
|
||||||
|
|
||||||
return _rv;
|
return _rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user