git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@345 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-15 18:55:41 +00:00
parent f71ab6184b
commit 39c09b1fb7
11 changed files with 292 additions and 264 deletions

View File

@@ -38,6 +38,14 @@ enum MwALIGNMENT {
*/ */
#define MwDEFAULT 0x0fffffff #define MwDEFAULT 0x0fffffff
/*!
* %brief Directory entry type
*/
enum {
MwDIRECTORY_FILE = 0,
MwDIRECTORY_DIRECTORY
};
/*! /*!
* %brief Icon mask * %brief Icon mask
*/ */

View File

@@ -42,7 +42,6 @@ MWDECL char* MwIconQuestion[];
*/ */
MWDECL char* MwIconWarning[]; MWDECL char* MwIconWarning[];
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -23,6 +23,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <signal.h> #include <signal.h>
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h>
#endif #endif
#ifndef M_PI #ifndef M_PI

View File

@@ -139,7 +139,7 @@ struct _MwSizeHints {
struct _MwDirectoryEntry { struct _MwDirectoryEntry {
char* name; char* name;
unsigned long attribute; int type;
}; };
#define MwCursorDataHeight 16 #define MwCursorDataHeight 16

View File

@@ -14,6 +14,7 @@ typedef struct dir {
#else #else
typedef struct dir { typedef struct dir {
DIR* dir; DIR* dir;
char* base;
} dir_t; } dir_t;
#endif #endif
@@ -35,6 +36,8 @@ void* MwDirectoryOpen(const char* path) {
free(dir); free(dir);
return NULL; return NULL;
} }
dir->base = malloc(strlen(path) + 1);
strcpy(dir->base, path);
#endif #endif
return dir; return dir;
@@ -46,6 +49,7 @@ void MwDirectoryClose(void* handle) {
FindClose(dir->hFind); FindClose(dir->hFind);
#else #else
closedir(dir->dir); closedir(dir->dir);
free(dir->base);
#endif #endif
free(handle); free(handle);
} }
@@ -62,14 +66,36 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
} }
entry->name = malloc(strlen(dir->ffd.cFileName) + 1); entry->name = malloc(strlen(dir->ffd.cFileName) + 1);
strcpy(entry->name, dir->ffd.cFileName); strcpy(entry->name, dir->ffd.cFileName);
if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
entry->type = MwDIRECTORY_DIRECTORY;
} else {
entry->type = MwDIRECTORY_FILE;
}
#else #else
struct dirent* d; struct dirent* d;
struct stat s;
char* p;
if((d = readdir(dir->dir)) == NULL) { if((d = readdir(dir->dir)) == NULL) {
free(entry); free(entry);
return NULL; return NULL;
} }
entry->name = malloc(strlen(d->d_name) + 1); entry->name = malloc(strlen(d->d_name) + 1);
strcpy(entry->name, d->d_name); strcpy(entry->name, d->d_name);
p = malloc(strlen(dir->base) + 1 + strlen(d->d_name) + 1);
strcpy(p, dir->base);
strcat(p, "/");
strcat(p, d->d_name);
stat(p, &s);
if(S_ISDIR(s.st_mode)) {
entry->type = MwDIRECTORY_DIRECTORY;
} else {
entry->type = MwDIRECTORY_FILE;
}
free(p);
#endif #endif
return entry; return entry;

View File

@@ -45,5 +45,4 @@ char *MwIconError[] = {
"..ooo.@@ .X.....o.@@@@ ...@@ ", "..ooo.@@ .X.....o.@@@@ ...@@ ",
" .oo.@ .XXXXooo.@@@ @@@ ", " .oo.@ .XXXXooo.@@@ @@@ ",
" ...@@ .ooooo.@@@ ", " ...@@ .ooooo.@@@ ",
" @@@@ .....@@ " " @@@@ .....@@ "};
};

View File

@@ -41,5 +41,4 @@ char *MwIconInfo[] = {
" ", " ",
" ", " ",
" ", " ",
" " " "};
};

View File

@@ -43,5 +43,4 @@ char *MwIconNews[] = {
" ..... ", " ..... ",
" ", " ",
" ", " ",
" " " "};
};

View File

@@ -45,5 +45,4 @@ char *MwIconNote[] = {
" .......+O+O+O.. ", " .......+O+O+O.. ",
" ..+OO..+O+.. ", " ..+OO..+O+.. ",
" ...+..... ", " ...+..... ",
" ..... " " ..... "};
};

View File

@@ -43,5 +43,4 @@ char *MwIconQuestion[] = {
" XXXXooOOO ", " XXXXooOOO ",
" XoooOOOO ", " XoooOOOO ",
" OOOOOO ", " OOOOOO ",
" OOOO " " OOOO "};
};

View File

@@ -43,5 +43,4 @@ char *MwIconWarning[] = {
" .............................oo", " .............................oo",
" ...........................ooo", " ...........................ooo",
" ooooooooooooooooooooooooooo ", " ooooooooooooooooooooooooooo ",
" " " "};
};