static int pakfire_file_classify_mode(struct pakfire_file* file) {
// Check for regular files
- if (S_ISREG(file->st.st_mode))
+ if (S_ISREG(file->st.st_mode)) {
file->class |= PAKFIRE_FILE_REGULAR;
+ // Does the file have executable permissions?
+ if (file->st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))
+ file->class |= PAKFIRE_FILE_EXECUTABLE;
+
// Check for directories
- else if (S_ISDIR(file->st.st_mode))
+ } else if (S_ISDIR(file->st.st_mode))
file->class |= PAKFIRE_FILE_DIRECTORY;
// Check for symlinks
const char* mimetype;
int class;
} mimetypes[] = {
- { "application/x-pie-executable", PAKFIRE_FILE_EXECUTABLE },
- { "application/x-sharedlibary", PAKFIRE_FILE_EXECUTABLE },
{ "text/x-perl", PAKFIRE_FILE_PERL },
{ NULL, 0 },
};
PAKFIRE_FILE_FIFO = (1 << 5),
PAKFIRE_FILE_SOCKET = (1 << 6),
+ // Is the file executable?
+ PAKFIRE_FILE_EXECUTABLE = (1 << 7),
+
// The rest
- PAKFIRE_FILE_ELF = (1 << 7),
- PAKFIRE_FILE_EXECUTABLE = (1 << 8),
+ PAKFIRE_FILE_ELF = (1 << 8),
PAKFIRE_FILE_PKGCONFIG = (1 << 9),
PAKFIRE_FILE_PERL = (1 << 10),
PAKFIRE_FILE_STATIC_LIBRARY = (1 << 11),