menu code cleanup and subdirectory support
menuitemmapload mapname action [hoveraction [desc]]
create menu entry for a map file
menudirlistsub action dots
adds subdirectory entries to a menu with a files list
has to come after the menudirlist command
<action> is the command to be executed, when the menu entry is chosen
if <dots> is 1, an entry ".." is added
enumfiles path [extension]
lists files in a directory
if extension is specified, only files of that extension are listed
if the extension is "dir", only directories are listed
DOCREF menuitemmapload menudirlistsub enumfiles
This commit is contained in:
@@ -279,7 +279,7 @@ bool listsubdir(const char *dir, vector<char *> &subdirs)
|
||||
if(Find != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do {
|
||||
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) subdirs.add(newstring(FindFileData.cFileName));
|
||||
if((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && FindFileData.cFileName[0] != '.') subdirs.add(newstring(FindFileData.cFileName));
|
||||
} while(FindNextFile(Find, &FindFileData));
|
||||
FindClose(Find);
|
||||
return true;
|
||||
@@ -294,12 +294,12 @@ bool listsubdir(const char *dir, vector<char *> &subdirs)
|
||||
while(!readdir_r(d, &b, &de) && de != NULL)
|
||||
{
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if(de->d_type == DT_DIR) subdirs.add(newstring(de->d_name));
|
||||
if(de->d_type == DT_DIR && de->d_name[0] != '.') subdirs.add(newstring(de->d_name));
|
||||
#else
|
||||
struct stat s;
|
||||
int dl = (int)strlen(pathname);
|
||||
concatformatstring(pathname, "/%s", de->d_name);
|
||||
if(!lstat(pathname, &s) && S_ISDIR(s.st_mode)) subdirs.add(newstring(de->d_name));
|
||||
if(!lstat(pathname, &s) && S_ISDIR(s.st_mode) && de->d_name[0] != '.') subdirs.add(newstring(de->d_name));
|
||||
pathname[dl] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user