Skip to content

Commit

Permalink
Remaining changes in autoconfiscation and
Browse files Browse the repository at this point in the history
loading of resource files using PKGDATADIR
  • Loading branch information
hishamhm committed Jan 4, 2007
1 parent d0faafa commit 0e97bd1
Show file tree
Hide file tree
Showing 11 changed files with 415 additions and 399 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
What's new in version 0.1
-------------------------

* Everything!

48 changes: 47 additions & 1 deletion Files.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

#include "Prototypes.h"

/*{
typedef bool(*Method_Files_fileHandler)(void*, char*);
}*/

FILE* Files_open(char* mode, char* picture, char* value) {
char fileName[4097];
char* dataDir = DATADIR;
char* dataDir = PKGDATADIR;
FILE* fd = Files_openHome(mode, picture, value);
if (fd) return fd;
snprintf(fileName, 4096, "%s/", dataDir);
Expand Down Expand Up @@ -34,3 +40,43 @@ void Files_makeHome() {
fileName[4095] = '\0';
mkdir(fileName, 0755);
}

void Files_forEachInDir(char* dirName, Method_Files_fileHandler fileHandler, void* data) {
bool result = false;
FILE* fd;
char homeName[4097];
char* homeDir = getenv("HOME");
snprintf(homeName, 4096, "%s/.dit/", homeDir);
int homeLen = strlen(homeName);
snprintf(homeName + homeLen, 4096 - homeLen, "%s", dirName);
DIR* dir = opendir(homeName);
while (dir) {
struct dirent* entry = readdir(dir);
if (!entry) break;
if (entry->d_name[0] == '.') continue;
snprintf(homeName + homeLen, 4096 - homeLen, "%s/%s", dirName, entry->d_name);
if (fileHandler(data, homeName)) {
if (dir) closedir(dir);
return;
}
}
char dataName[4097];
char* dataDir = PKGDATADIR;
snprintf(dataName, 4096, "%s/", dataDir);
int dataLen = strlen(dataName);
snprintf(dataName + dataLen, 4096 - homeLen, "%s", dirName);
dir = opendir(dataName);
while (dir) {
struct dirent* entry = readdir(dir);
if (!entry) break;
if (entry->d_name[0] == '.') continue;
snprintf(homeName + homeLen, 4096 - homeLen, "%s/%s", dirName, entry->d_name);
if (access(homeName, R_OK) == 0)
continue;
snprintf(dataName + dataLen, 4096 - dataLen, "%s/%s", dirName, entry->d_name);
if (fileHandler(data, dataName)) {
if (dir) closedir(dir);
return;
}
}
}
121 changes: 0 additions & 121 deletions GenHeaders

This file was deleted.

Loading

0 comments on commit 0e97bd1

Please sign in to comment.