|
@@ -194,9 +194,8 @@ void la_FileBrowserRebuildList(laFileBrowser *fb){
|
|
|
long long TotalSpace = 0;
|
|
|
real Ratio = 0;
|
|
|
|
|
|
- if (fb->Path[len - 1] != L'/') strcat(fb->Path, "/");
|
|
|
-
|
|
|
#ifdef __linux__
|
|
|
+ if (fb->Path[len - 1] != L'/') strcat(fb->Path, "/");
|
|
|
struct dirent **NameList=0;
|
|
|
int NumFiles=scandir(fb->Path,&NameList,0,alphasort);
|
|
|
|
|
@@ -237,19 +236,62 @@ void la_FileBrowserRebuildList(laFileBrowser *fb){
|
|
|
}
|
|
|
for (int i = 0; i < NumFiles; i++) { free(NameList[i]); } free(NameList);
|
|
|
#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ WIN32_FIND_DATA FindFileData;
|
|
|
+ HANDLE hFind;
|
|
|
+ SYSTEMTIME stUTC, stLocal;
|
|
|
+ strCopyFull(Lookup, fb->Path);
|
|
|
+ if (Lookup[len - 1] != L'\\') strcat(Lookup, "\\*.*"); else strcat(Lookup, "*.*");
|
|
|
+ hFind = FindFirstFile(Lookup, &FindFileData);
|
|
|
+
|
|
|
+ while (fi = lstPopItem(&fb->FileList)) memFree(fi);
|
|
|
+
|
|
|
+ if (hFind == INVALID_HANDLE_VALUE){ return; }
|
|
|
+
|
|
|
+ while (1) {
|
|
|
+ if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
|
|
+ if (FindFileData.cFileName[0] != '.') {
|
|
|
+ fi = memAcquireSimple(sizeof(laFileItem));
|
|
|
+ strcpy(fi->Name, FindFileData.cFileName);
|
|
|
+ fi->IsFolder = 1;
|
|
|
+ fi->Type = LA_FILETYPE_FOLDER;
|
|
|
+ lstAppendItem(&fb->FileList, fi);
|
|
|
+ }
|
|
|
+ }elif(!fb->SelectFolder) {
|
|
|
+ fi = memAcquireSimple(sizeof(laFileItem));
|
|
|
+ strCopyFull(fi->Name, FindFileData.cFileName);
|
|
|
+ fi->Size = FindFileData.nFileSizeLow;
|
|
|
+ fi->Type = la_DetectFileItemType(fi);
|
|
|
+
|
|
|
+ FileTimeToSystemTime(&(FindFileData.ftLastWriteTime), &stUTC);
|
|
|
+ SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
|
|
|
+
|
|
|
+ fi->TimeModified.Year = stLocal.wYear;
|
|
|
+ fi->TimeModified.Month = stLocal.wMonth;
|
|
|
+ fi->TimeModified.Day = stLocal.wDay;
|
|
|
+ fi->TimeModified.Hour = stLocal.wHour;
|
|
|
+ fi->TimeModified.Minute = stLocal.wMinute;
|
|
|
+ fi->TimeModified.Second = stLocal.wSecond;
|
|
|
+
|
|
|
+ lstAppendItem(&Files, fi);
|
|
|
+ //lstAppendItem(&fb->FileList, fi);
|
|
|
+ }
|
|
|
+ if (!FindNextFile(hFind, &FindFileData))
|
|
|
+ break;
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
lstCombineLists(&fb->FileList, &Files);
|
|
|
|
|
|
while (dl = lstPopItem(&fb->Disks)) memFree(dl);
|
|
|
|
|
|
- NumDisks = GetLogicalDriveStrings(256, DiskLabels) / 4;
|
|
|
-
|
|
|
#ifdef _WIN32
|
|
|
+ NumDisks = GetLogicalDriveStrings(256, DiskLabels) / 4;
|
|
|
while (*pd){
|
|
|
char Name[3] = "*:";
|
|
|
Name[0] = *pd;
|
|
|
if (GetDiskFreeSpaceEx(Name, &FreeAvailable, &TotalSpace, &FreeSpace_UNUSED)){
|
|
|
- dl = memAcquireSimple(sizeof(laDiskItem));
|
|
|
+ dl = memAcquire(sizeof(laDiskItem));
|
|
|
dl->ID = *pd;
|
|
|
dl->Total_GB = (real)TotalSpace / 1073741824.0f; //B->GB
|
|
|
dl->Free_GB = (real)FreeAvailable / 1073741824.0f; //B->GB
|
|
@@ -278,6 +320,7 @@ laFileBrowser *la_FileBrowserInit(laOperator *a){
|
|
|
if ((arg=strGetArgumentString(a->ExtraInstructionsP, "filter_type"))){ sscanf(arg,"%d",&fb->FilterType); }
|
|
|
if ((arg=strGetArgumentString(a->ExtraInstructionsP, "use_type"))){ sscanf(arg,"%d",&fb->UseType); }
|
|
|
|
|
|
+#ifdef __linux__
|
|
|
char BookmarkPath[1024];
|
|
|
strcat(strcpy(BookmarkPath, getenv("HOME")), "/.config/gtk-3.0/bookmarks");
|
|
|
FILE* f=fopen(BookmarkPath, "r");
|
|
@@ -289,6 +332,7 @@ laFileBrowser *la_FileBrowserInit(laOperator *a){
|
|
|
}
|
|
|
fclose(f);
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
la_FileBrowserRebuildList(fb);
|
|
|
fb->FileName[0] = 0;
|
|
@@ -300,7 +344,7 @@ void laset_FileBrowserSelectFile(laFileBrowser *fb, laFileItem *fi, int State){
|
|
|
if (fb->Active == fi){
|
|
|
if (fi->IsFolder){
|
|
|
len = strlen(fb->Path);
|
|
|
- if (fb->Path[len - 1] != L'/') strcat(fb->Path, "/");
|
|
|
+ if (fb->Path[len - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
|
|
|
strcat(fb->Path, fi->Name);
|
|
|
la_FileBrowserRebuildList(fb);
|
|
|
fb->FileName[0] = 0;
|
|
@@ -317,7 +361,7 @@ void la_FileBrowserGetFullPath(laFileBrowser *fb,char* buf){
|
|
|
buf[0]=0; int plen;
|
|
|
if (!fb->SelectFolder && fb->FileName[0] == L'\0') return;
|
|
|
plen = strlen(fb->Path);
|
|
|
- if (fb->Path[plen - 1] != L'/') strcat(fb->Path, "/");
|
|
|
+ if (fb->Path[plen - 1] != LA_PATH_SEP) strcat(fb->Path, LA_PATH_SEPSTR);
|
|
|
strCopyFull(buf, fb->Path);
|
|
|
strcat(buf, fb->FileName);
|
|
|
}
|
|
@@ -336,7 +380,7 @@ void *laget_FileBrowserActiveFile(laFileBrowser *fb){
|
|
|
void laget_FileBrowserDiskID(laDiskItem *di, char *result){
|
|
|
result[0] = di->ID;
|
|
|
result[1] = L':';
|
|
|
- result[2] = L'/';
|
|
|
+ result[2] = LA_PATH_SEP;
|
|
|
result[3] = L'\0';
|
|
|
}
|
|
|
void *laset_FileBrowserActiveDisk(laFileBrowser *fb, laDiskItem *di, int UNUSED_State){
|
|
@@ -388,7 +432,7 @@ void la_FileBrowserUpLevel(laFileBrowser *fb){
|
|
|
char *LastP = 0;
|
|
|
int Count = 0;
|
|
|
for (p; *p; p++){
|
|
|
- if (*p && *p == L'/' && p[1]!=0){
|
|
|
+ if (*p && *p == LA_PATH_SEP && p[1]!=0){
|
|
|
LastP = p;
|
|
|
Count++;
|
|
|
}
|
|
@@ -605,7 +649,7 @@ int OPMOD_ManagedSaveNewFile(laOperator *a, laEvent *e){
|
|
|
return LA_FINISHED;
|
|
|
}
|
|
|
laManagedUDF* m=MAIN.DummyManageUDF;
|
|
|
- m->udf = laPrepareUDF(path); strSafeSet(&m->BaseName, strGetLastSegment(path,'/'));
|
|
|
+ m->udf = laPrepareUDF(path); strSafeSet(&m->BaseName, strGetLastSegment(path,LA_PATH_SEP));
|
|
|
m->udf->Managed=1;
|
|
|
la_MakeDummyManagedUDF();
|
|
|
laNotifyUsers("la.managed_udfs"); laNotifyUsers("la.managed_props");
|
|
@@ -2120,7 +2164,7 @@ void la_RegisterBuiltinOperators(){
|
|
|
laAddStringProperty(pc, "path", "Path", "Directort Path", 0, 0, 0, "/", 0, offsetof(laFileBrowser, Path), 0, 0, laset_FileBrowserPath, 0, LA_UDF_LOCAL);
|
|
|
laAddStringProperty(pc, "file_name", "File Name", "File Name", 0, 0, 0, 0, 0, offsetof(laFileBrowser, FileName), 0, 0, laset_FileBrowserFileName, 0, LA_UDF_LOCAL);
|
|
|
laAddSubGroup(pc, "file_list", "File List", "List Of Files And Directories Under A Specific Path", "file_item",0,0,laui_FileBrowserFileItem, -1, 0, laget_FileBrowserActiveFile, 0, 0, 0, laset_FileBrowserSelectFile, offsetof(laFileBrowser, FileList), 0);
|
|
|
- laAddSubGroup(pc, "disk_list", "Disk List", "List Of All Logical Drives (In Windows)", "disk_item",0, 0, 0, offsetof(laFileBrowser, RootDisk), 0, 0, 0, 0, 0, laset_FileBrowserActiveDisk, offsetof(laFileBrowser, Disks), 0);
|
|
|
+ laAddSubGroup(pc, "disk_list", "Disk List", "List Of All Logical Drives (In Windows)", "disk_item",0, 0, 0, -1, 0, 0, 0, 0, 0, laset_FileBrowserActiveDisk, offsetof(laFileBrowser, Disks), 0);
|
|
|
laAddSubGroup(pc, "bookmarks", "Bookmarks", "Bookmarked directories in GTK3", "bookmarked_folder",0, 0, 0, -1, 0, 0, 0, laset_FileBrowserBookmark, 0, 0, offsetof(laFileBrowser, Bookmarks), 0);
|
|
|
laAddSubGroup(pc, "available_extensions", "Available Extensions", "List of all available extensions", "la_extension_type",0, 0, 0, 0, laget_FileBrowserAcceptedExtensionsFrist, 0, laget_FileBrowserAcceptedExtensionsNext,laset_FileBrowserExtension,0,0,0,0);
|
|
|
laAddIntProperty(pc,"use_type","Use Type","Use file type",0,0,0,0,0,0,0,0,offsetof(laFileBrowser,UseType),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY);
|
|
@@ -2130,7 +2174,7 @@ void la_RegisterBuiltinOperators(){
|
|
|
}
|
|
|
laAddOperatorProperty(pc, "folder_up", "Up", "Select Upper Folder Level In File Browsers", "LA_file_dialog_up", L'🢰', 0);
|
|
|
laAddOperatorProperty(pc, "confirm", "Confirm", "Confirm selection", "LA_file_dialog_confirm", L'✔', 0);
|
|
|
- p = laAddPropertyContainer("disk_item", "Disk Item", "A Logical Drive (In Windows)", 0, laui_FileBrowserDiskItem, 0, 0, 0, 0);{
|
|
|
+ p = laAddPropertyContainer("disk_item", "Disk Item", "A Logical Drive (In Windows)", 0, laui_FileBrowserDiskItem, 0, 0, 0, 1);{
|
|
|
laAddStringProperty(p, "id", "ID", "Disk Identifier", 0, 0, 0, 0, 0, 0, 0, laget_FileBrowserDiskID, 0, 0, 0);
|
|
|
laAddFloatProperty(p, "total_gb", "Total", "Disk Total Compacity In Gigabytes", 0, 0, "GB", 0, 0, 0, 0, 0, offsetof(laDiskItem, Total_GB), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
|
|
|
laAddFloatProperty(p, "free_gb", "Free", "Disk Free Space Size In Gigabytes", 0, 0, "GB", 0, 0, 0, 0, 0, offsetof(laDiskItem, Free_GB), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,LA_READ_ONLY);
|