X-Git-Url: https://ecere.com/cgi-bin/gitweb.cgi?p=ede;a=blobdiff_plain;f=libede%2Fsrc%2FFileSystemBox.ec;h=fda27faa541d76d6d0726c5f05a2928586bdab0c;hp=aa2d30440a478f8eaa4926a43e55d3683b6454d3;hb=4943336814b7b33a190e420e7ed6014921522014;hpb=af726215c6576ef2134150ca2c4a4f2f12d9f4eb diff --git a/libede/src/FileSystemBox.ec b/libede/src/FileSystemBox.ec index aa2d304..fda27fa 100644 --- a/libede/src/FileSystemBox.ec +++ b/libede/src/FileSystemBox.ec @@ -139,13 +139,20 @@ public enum _FileType class FileSystemBoxBits { - bool foldersOnly:1, filesOnly:1, details:1, treeBranches:1, previewPictures:1, navigateFolders:1; + bool foldersOnly:1, filesOnly:1, details:1, pathColumn:1, treeBranches:1, previewPictures:1, navigateFolders:1, autoLoad:1; + bool preview:1; //bool header:1, freeSelect:1, fullRowSelect:1, multiSelect:1, autoScroll:1, alwaysHL : 1, moveRows:1, resizable:1; //bool moveFields:1, clearHeader:1, alwaysEdit:1, collapse:1, treeBranch:1, rootCollapse:1, heightSet:1; //bool sortable:1, noDragging:1, fillLastField:1, expandOnAdd:1; }; public class FileSystemBox : Window // should we not derive from ListBox instead? + // I say we should, but we can't right now... + // because ListBox (inside ecere library) is + // not exposing enough internal machinery... + // could we not have a different private and + // public mechanism when deriving a class than + // we do when simply instanciating a class? /* this stuff from the listbox would be nicely exposed... fullRowSelect = false; @@ -163,10 +170,11 @@ public class FileSystemBox : Window // should we not derive from ListBox instead public: FileSystemNode root; - FileSystemNode selection; + FileSystemBoxSelection selection { }; - virtual bool Window::NotifyNodeSelect(FileSystemBox box, FileSystemNode node); - virtual bool Window::NotifyNodeOpen(FileSystemBox box, FileSystemNode node); + virtual bool Window::NotifyNodeSelect(FileSystemBox box, FileSystemBoxSelection selection); + //virtual bool Window::NotifyNodeNavigate(FileSystemBox box, FileSystemNode node); + virtual bool Window::NotifyNodeOpen(FileSystemBox box, FileSystemBoxSelection selection); property char * path { @@ -189,7 +197,8 @@ public: property bool filesOnly { set { bits.filesOnly = value; bits.foldersOnly = !value; } get { return bits.filesOnly; } }; property bool previewPictures { set { bits.previewPictures = value; } get { return bits.previewPictures; } }; property char * extensions { set { delete extensions; if(value && value[0]) extensions = CopyString(value); } get { return extensions; } } - property bool details { set { bits.details = value; } get { return bits.details; } }; + property bool details { set { bits.details = value; ChangeViewType(); } get { return bits.details; } }; + property bool pathColumn { set { bits.pathColumn = value; ChangeViewType(); } get { return bits.pathColumn; } }; property bool treeBranches { set @@ -201,8 +210,23 @@ public: } get { return bits.treeBranches; } }; + property Color selectionColor { set { list.selectionColor = value; } get { return list.selectionColor; }/* isset { return selectionColor ? true : false; }*/ }; + property Color selectionText { set { list.selectionText = value; } get { return list.selectionText; }/* isset { return selectionText ? true : false; }*/ }; property bool navigateFolders { set { bits.navigateFolders = value; bits.filesOnly = !value; } get { return bits.navigateFolders; } }; property bool multiSelect { set { list.multiSelect = value; } get { return list.multiSelect; } }; + property bool autoLoad { set { bits.autoLoad = value; } get { return bits.autoLoad; } }; + property bool hasHeader { set { list.hasHeader = value; } get { return list.hasHeader; } }; + property bool preview + { + set + { + bits.preview = value; + split.leftPane = value ? list : null; + split.visible = value; + show.visible = value; + } + get { return bits.preview; } + }; property FileSystemNode node { @@ -229,16 +253,106 @@ public: } } + void SelectMultipleByPath(Array paths) + { + DataRow row; + bool firstRow = false; + Map map { }; + for(path : paths) + map[path] = true; + for(row = list.firstRow; row; row = row.next) + { + FileSystemNode node = (FileSystemNode)row.tag; + if(map[node.path]) + { + if(!firstRow) + { + list.SelectRow(row); + firstRow = true; + } + else + row.selected = true; + } + else + row.selected = false; + } + delete map; + } + + FileSystemNode SelectLocation(char * location) + { + int c; + char * temp; + char step[MAX_LOCATION]; + + //StringArray steps { growingFactor = 4 }; + Array steps { }; + FileSystemNode result = null; + FileSystemNode node = null; + + temp = CopyString(location); + while(temp[0]) + { + GetLastDirectory(temp, step); + StripLastDirectory(temp, temp); + steps.Add(CopyString(step)); + } + + for(c = steps.count - 1; c >= 0; c--) + { + char * t = steps[c]; + node = Find(steps[c], node); + if(!node) + break; + //Select(node); + } + if(node) + { + result = node; + Select(result); + } + + steps.Free(); + delete temp; + delete steps; + + return result; + } + FileSystemNode Find(const char * name, FileSystemNode parent) { - FileSystemNode node; - FileSystemNode start = parent ? parent : root; - if(!start.loaded || !start.childrenLoaded) - LoadTreeNode(start); - for(node = start.children.first; node; node = node.next) - if(node.name && !strcmpi(node.name, name)) - return node; - return null; + FileSystemNode node = null; + FileSystemNode result = null; + if(!parent/* && !strcmp(name, "/")*/) + { + DataRow row; + for(row = list.firstRow; row; row = row.next) + { + node = (FileSystemNode)row.tag; + if(node.name && !fstrcmp(node.name, name)) + break; + } + if(node) + result = node; + //result = root; + } + else + { + FileSystemNode start = parent ? parent : root; + if(!start.bits.loaded || !start.bits.childrenLoaded) + LoadTreeNode(start); + for(node = start.children.first; node; node = node.next) + if(node.name && !fstrcmp(node.name, name)) + break; + if(node) + result = node; + } + return result; + } + + void Clear() + { + list.Clear(); } void Refresh() @@ -254,6 +368,9 @@ private: BitmapResource fileIcons[_FileType]; + Bitmap bitmap; + //BitmapArray bitmaps { growingFactor = 16 }; + FileSystemBox() { char wd[MAX_LOCATION]; @@ -262,12 +379,20 @@ private: InitFileIcons(); list.AddField(nameField); + bits.autoLoad = true; } + ~FileSystemBox() { delete extensions; delete path; } + + watch(background) + { + list.background = background; + }; + void InitFileIcons() { _FileType c; @@ -278,13 +403,16 @@ private: } } - DataField nameField { dataType = "FileSystemNode", width = 240, userData = this, freeData = false }; + DataField nameField { header = "Name", dataType = "FileSystemNode", width = 240, userData = this, freeData = false }; + DataField pathField { header = "Location", dataType = /*"String"*/ "char *", width = 300, freeData = false }; DataField typeField { header = "Type", dataType = /*"String"*/ "char *", width = 40, freeData = false }; DataField sizeField { header = "Size", dataType = "FileSize", width = 96, alignment = right, freeData = false }; + DataField modifiedField { header = "Modified", dataType = "SecSince1970", width = 96, alignment = right, freeData = false }; bool OnPostCreate() { - Load(); + if(bits.autoLoad) + Load(); return true; } @@ -297,6 +425,7 @@ private: hasVertScroll = true; fullRowSelect = false; sortable = true; + alwaysHighLight = true; anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 }; @@ -329,7 +458,7 @@ private: } else { - if(!node.loaded || !node.childrenLoaded) + if(!node.bits.loaded || !node.bits.childrenLoaded) { LoadTreeNode(node); //list.Sort(nameField, 1); @@ -351,9 +480,14 @@ private: FileSystemNode node = (FileSystemNode)row.tag; if(node) { + char * text; + PopupMenu popup; Menu menu { }; + text = PrintString("Open ", node.path); + + MenuItem { menu, text, o, NotifySelect = MenuOpen, disabled = false }; MenuItem { menu, "Cut\tCtrl+X", t, NotifySelect = null, disabled = false }; MenuItem { menu, "Copy\tCtrl+C", c, NotifySelect = null, disabled = false }; MenuItem { menu, "Paste\tCtrl+V", p, NotifySelect = null, disabled = false /*!clipboard*/ }; @@ -375,12 +509,57 @@ private: bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods) { - if(row) + OldList rows; + OldLink item; + + selection.nodes.Free(); + list.GetMultiSelection(rows); + for(item = rows.first; item; item = item.next) { + DataRow row = item.data; FileSystemNode node = (FileSystemNode)row.tag; - NotifyNodeSelect(listBox.parent.master, this, node); - selection = node; + selection.nodes.Add(node); + incref node; + } + rows.Free(null); + if(row) + selection.node = (FileSystemNode)row.tag; + else + selection.node = null; + + if(selection.node && bits.preview) + { + //int pos; + FileSystemNode node = selection.node; + /*if(bitmap) + bitmap.Free();*/ + delete bitmap; + if(node && node.type == pictureFile) + { + bitmap = Bitmap { }; + bitmap.Load(node.path, null, displaySystem); + } + + /*bitmaps.Clear(); + bitmaps = BitmapArray { }; + for(pos = 0; pos < selectedItems.count; pos++) + { + Bitmap bitmap { }; + selItem = (ExplorerFileItem)selectedItems._[pos]; + bitmap.Load(selItem.path, null, displaySystem); + //bitmaps.Add(bitmap); + } + if(node && node.type == pictureFile) + { + bitmap = Bitmap { }; + bitmap.Load(node.path, null, displaySystem); + }*/ + + show.Update(null); + //NotifyItemSelect(master, view, item, selectedItems); } + + NotifyNodeSelect(listBox.parent.master, this, selection); return true; } @@ -413,8 +592,9 @@ private: bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods) { + bool result = !(selection.node && selection.node.type.isFolder && bits.navigateFolders); OpenNode(); - return false; + return result; } bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch) @@ -428,16 +608,69 @@ private: } }; - bool OpenNode() + PaneSplitter split { - bool result; - if(selection && selection.type.isFolder && bits.navigateFolders) + this; + //leftPane = list; + rightPane = show; + //split = 200; + scaleSplit = 0.5f; + tabCycle = true; + visible = false; + }; + + Window show + { + this; + visible = false; + borderStyle = none; + anchor = Anchor { top = 0, right = 0, bottom = 0 }; + + void OnRedraw(Surface surface) { - property::path = selection.path; - result = true; + FileSystemBox fsb = (FileSystemBox)parent; + if(fsb.bitmap) + { + int wBmp = fsb.bitmap.width; + int hBmp = fsb.bitmap.height; + int wWnd = fsb.show.clientSize.w; + int hWnd = fsb.show.clientSize.h; + + int wList = 0;//fsb.list.size.w + fsb.split.size.w; + + float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp); + + int wDraw = (int)(wBmp * scale); + int hDraw = (int)(hBmp * scale); + + #ifndef __linux__ + surface.Filter(fsb.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp); + #else + // Until Filter / Stretch works with X + surface.Blit(fsb.bitmap, (wWnd - wBmp) / 2, (hWnd - hBmp) / 2, 0, 0, wBmp, hBmp); + #endif + } + else + { + surface.SetForeground(white); + surface.Area(0, 0, fsb.clientSize.w - 1, fsb.clientSize.h - 1); + } } - else - result = NotifyNodeOpen(this.master, this, selection); + } + + bool MenuOpen(MenuItem selection, Modifiers mods) + { + OpenNode(); + } + + bool OpenNode() + { + bool result; + FileSystemBoxSelection selection = this.selection.Copy(); + FileSystemNode node = selection.node; + if(node && node.type.isFolder && bits.navigateFolders) + property::path = node.path; + result = NotifyNodeOpen(this.master, this, selection); return result; } @@ -491,6 +724,24 @@ private: nameField.width = width - 80; }*/ + void ChangeViewType() + { + list.Clear(); + list.ClearFields(); + list.resizable = bits.details || bits.pathColumn; + list.moveFields = bits.details || bits.pathColumn; + list.hasHeader = bits.details || bits.pathColumn; + list.AddField(nameField); + if(bits.pathColumn) + list.AddField(pathField); + if(bits.details) + { + list.AddField(typeField); + list.AddField(sizeField); + list.AddField(modifiedField); + } + } + void Load() { // TODO: fix this! @@ -522,15 +773,8 @@ private: (bits.foldersOnly && listing.stats.attribs.isDirectory) || (bits.filesOnly && listing.stats.attribs.isFile)) { - FileSystemNode node = MakeFileSystemNode(listing.stats, listing.name, listing.path, bits.previewPictures, displaySystem); - DataRow row = list.AddRow(); - row.tag = (int)node; - row.SetData(nameField, node); - if(bits.details) - { - row.SetData(typeField, node.extension); - row.SetData(sizeField, (void *)node.stats.size); - } + FileSystemNode node = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, displaySystem); + AddNode(node); } } list.Sort(nameField, 1); @@ -539,10 +783,15 @@ private: void LoadTree() { bool isRoot = !strcmp(path, "/"); - //char startPath[MAX_LOCATION]; + char name[MAX_LOCATION]; FileSystemNode parent; FileSystemNode node; FileListing listing { path, extensions = extensions }; + + if(!isRoot) + GetLastDirectory(path, name); + else + name[0] = '\0'; /*if(!path) GetWorkingDir(startPath, sizeof(startPath)); @@ -555,7 +804,7 @@ private: #ifdef __WIN32__ if(isRoot) { - root = FileSystemNode { loaded = true, childrenLoaded = true }; + root = FileSystemNode { bits.loaded = true, bits.childrenLoaded = true }; AddTreeNode(root, true, false, null); while(listing.Find()) { @@ -576,13 +825,13 @@ private: info[0] = 0; } - parent = MakeFileSystemNode(listing.stats, name, listing.path, bits.previewPictures, displaySystem); + parent = MakeFileSystemNode(listing.stats, name, listing.path, false, bits.previewPictures, displaySystem); if(info[0]) - parent.info = CopyString(info); - parent.loaded = true; + parent.info = info; //CopyString(info); + parent.bits.loaded = true; AddTreeNode(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root); if(!listing.stats.attribs.isDirectory) - parent.childrenLoaded = true; + parent.bits.childrenLoaded = true; } node = FileSystemNode { name = msNetwork, type = network }; @@ -592,7 +841,7 @@ private: else #endif { - root = MakeFileSystemNode(FileStats { attribs = FileExists(path)}, path, path, bits.previewPictures, displaySystem); + root = MakeFileSystemNode(FileStats { attribs = FileExists(path)}, name, path, false, bits.previewPictures, displaySystem); AddTreeNode(root, false, true, null); LoadTreeNode(root); } @@ -600,7 +849,7 @@ private: if(isRoot) { root.type = computer; - root.name = rootName; + root.label = rootName; } list.Sort(nameField, 1); @@ -609,7 +858,7 @@ private: void LoadTreeNode(FileSystemNode node) { - if(!node.loaded) + if(!node.bits.loaded) { char path[MAX_LOCATION]; node.GetPath(path); @@ -624,29 +873,29 @@ private: (bits.foldersOnly && listing.stats.attribs.isDirectory) || (bits.filesOnly && listing.stats.attribs.isFile))) { - FileSystemNode child = MakeFileSystemNode(listing.stats, listing.name, listing.path, bits.previewPictures, displaySystem); + FileSystemNode child = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, displaySystem); AddTreeNode(child, true, false, node); NodeChildLoad(child, node); } } } - node.childrenLoaded = true; - node.loaded = true; + node.bits.childrenLoaded = true; + node.bits.loaded = true; node.row.SortSubRows(false); } - else if(!node.childrenLoaded) + else if(!node.bits.childrenLoaded) { FileSystemNode child; if(node.children.first) { for(child = node.children.first; child; child = child.next) { - if(!child.loaded) + if(!child.bits.loaded) LoadTreeNode(child); - else if(!child.childrenLoaded) + else if(!child.bits.childrenLoaded) NodeChildLoad(child, node); } - node.childrenLoaded = true; + node.bits.childrenLoaded = true; node.row.SortSubRows(false); } } @@ -665,15 +914,35 @@ private: (bits.foldersOnly && listing.stats.attribs.isDirectory) || (bits.filesOnly && listing.stats.attribs.isFile)) { - FileSystemNode child = MakeFileSystemNode(listing.stats, listing.name, listing.path, bits.previewPictures, displaySystem); - AddTreeNode(child, true, false, parent); + FileSystemNode child = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, displaySystem); + AddTreeNode(child, listing.stats.attribs.isFile, !listing.stats.attribs.isFile, parent); added = true; } } if(!added) added = true; } - //parent.childrenLoaded = true; + parent.bits.childrenLoaded = true; + } + + void AddNode(FileSystemNode node) + { + DataRow row = list.AddRow(); + row.tag = (int)node; + node.row = row; + incref node; + row.SetData(nameField, node); + if(bits.pathColumn) + row.SetData(pathField, node.path); + if(bits.details) + { + if(node.type.isFile) + { + row.SetData(typeField, node.extension); + row.SetData(sizeField, /*(void *)*/node.stats.size); + } + row.SetData(modifiedField, node.stats.modified); + } } void AddTreeNode(FileSystemNode node, bool loaded, bool addLoader, FileSystemNode addTo) @@ -688,8 +957,19 @@ private: row.tag = (int)node; node.row = row; row.SetData(null, node); + if(bits.pathColumn) + row.SetData(pathField, node.path); + if(bits.details) + { + if(node.type.isFile) + { + row.SetData(typeField, node.extension); + row.SetData(sizeField, /*(void *)*/node.stats.size); + } + row.SetData(modifiedField, node.stats.modified); + } - node.loaded = loaded; + node.bits.loaded = loaded; if(addLoader) //AddTreeNode(FileSystemNode { }, false, false, node); // why would this create a compile error? AddTreeNode(FileSystemNode { type = none }, false, false, node); @@ -703,10 +983,15 @@ private: void DeleteNode(FileSystemNode node) { FileSystemNode child; - for(; (child = node.children.first); ) - DeleteNode(child); + if(treeBranches) + { + for(; (child = node.children.first); ) + DeleteNode(child); + } list.DeleteRow(node.row); node.Delete(); + //delete node; + //Update(null); } } @@ -1768,9 +2053,52 @@ ExplorerFileItem MakeFileItem(const FileAttribs attribs, const char * fileName, #endif */ -public class FileSystemNode : struct +public class FileSystemBoxSelection { public: + FileSystemNode node; + Array nodes { }; + +private: + FileSystemBoxSelection Copy() + { + FileSystemBoxSelection copy { node = node }; + for(node : nodes) + { + copy.nodes.Add(node); + incref node; + } + return copy; + } + + ~FileSystemBoxSelection() + { + nodes.Free(); + } +} + +class FileSystemNodeBits +{ + bool loaded:1, childrenLoaded:1, displayPath:1; +}; + +public class FileSystemNode +{ + +private: + FileSystemNodeBits bits; + char * path; + char * name; + char * extension; + char * label; + char * info; + + ~FileSystemNode() + { + Free(); + } + +public: /*//LinkElement link; FileSystemNode parent; @@ -1780,12 +2108,34 @@ public: FileSystemNode prev, next; - bool loaded, childrenLoaded; int indent; - char * path; - char * name; - char * extension; - char * info; + + property char * path + { + set { delete path; if(value && value[0]) path = CopyString(value); } + get { return path; } isset { return path && path[0]; } + } + property char * name + { + set { delete name; if(value && value[0]) name = CopyString(value); } + get { return name; } isset { return name && name[0]; } + } + property char * extension + { + set { delete extension; if(value && value[0]) extension = CopyString(value); } + get { return extension; } isset { return extension && extension[0]; } + } + property char * label + { + set { delete label; if(value && value[0]) label = CopyString(value); } + get { return label; } isset { return label && label[0]; } + } + property char * info + { + set { delete info; if(value && value[0]) info = CopyString(value); } + get { return info; } isset { return info && info[0]; } + } + DataRow row; OldList children; _FileType type; @@ -1797,10 +2147,13 @@ public: void GetPath(String outputPath) { - FileSystemNode up; - if(parent) + if(path) + strcpy(outputPath, path); + else if(parent) { - strcpy(outputPath, name); + FileSystemNode up; + if(name) + strcpy(outputPath, name); for(up = parent; up; up = up.parent) { char temp[MAX_LOCATION]; @@ -1808,14 +2161,17 @@ public: PathCat(temp, outputPath); strcpy(outputPath, temp); } + /*else + { + /-*#ifdef __WIN32__ + strcpy(outputPath, "/"); + #else*-/ + //strcpy(outputPath, name); + strcpy(outputPath, path); + PathCat(outputPath, name); + //#endif + }*/ } - else -/*#ifdef __WIN32__ - strcpy(outputPath, "/"); -#else*/ - strcpy(outputPath, name); -//#endif - } bool IsChildOf(FileSystemNode node) @@ -1836,9 +2192,9 @@ public: for(child = children.first; child; child = child.next) { FileSystemNode copy { }; - copy.name = CopyString(child.name); + copy.name = child.name; //CopyString(child.name); copy.type = child.type; - fsb.AddTreeNode(copy, child.loaded, false, addTo); + fsb.AddTreeNode(copy, child.bits.loaded, false, addTo); if(forceExpanded) copy.row.collapsed = false; if(recursive) @@ -1870,7 +2226,10 @@ public: children.Delete(child); } //if(name) + delete path; delete name; + delete extension; + delete label; delete info; } @@ -1889,7 +2248,7 @@ public: int len; int w, h; //int textOffset; - char label[MAX_FILENAME]; + char string[MAX_FILENAME]; Bitmap icon; @@ -1904,10 +2263,10 @@ public: return; if(info) - sprintf(label, "%s [%s]", name, info); + sprintf(string, "%s [%s]", label ? label : name, info); else - strcpy(label, name); - len = strlen(label); + strcpy(string, label ? label : name); + len = strlen(string); if(!icon) { @@ -1918,8 +2277,9 @@ public: } //textOffset = indent * indentSize + (icon ? (icon.width + 4) : 0); + surface.SetForeground(displayFlags.selected ? fsb.selectionText : fsb.foreground); surface.TextOpacity(false); - surface.TextExtent(label, len, &w, &h); + surface.TextExtent(string, len, &w, &h); h = Max(h, 16); // Draw the current row stipple @@ -1929,7 +2289,7 @@ public: surface.Area(xStart - 3, y, xStart + w + 1, y + h - 1); //surface.WriteTextDots(alignment, x + textOffset, y + 2, width - textOffset, name, strlen(name)); - surface.WriteTextDots(alignment, xStart, y + 2, width, label, len); + surface.WriteTextDots(alignment, xStart, y + 2, width, string, len); if(!guiApp.textMode) { @@ -2046,18 +2406,33 @@ public: } return node; }*/ -static FileSystemNode MakeFileSystemNode(const FileStats stats, - const char * fileName, const char * filePath, - const bool previewPicture, const DisplaySystem displaySystem) + +FileSystemNode MakeFileSystemNode( + const FileStats stats, + const char * name, + const char * path, + const bool pathAddName, + const bool previewPicture, + const DisplaySystem displaySystem) { - int len = strlen(fileName); + int len = strlen(name); char info[MAX_LOCATION]; - char name[MAX_LOCATION]; + char name2[MAX_LOCATION]; char extension[MAX_EXTENSION]; FileSystemNode node { stats = stats }; - //if(stats.attribs.isFile) // TODO fix this in ecere + /*if(!pathAddName) + { + char o[MAX_LOCATION]; + //char r[MAX_LOCATION]; + //StripLastDirectory(path, o); + GetLastDirectory(path, o); + if(fstrcmp(name, o)) + //if(!FileExists(path)) + PrintLn("Stop!"); + }*/ + //if(stats.attribs.isFile) // TODO fix this in ecere -- WTH -- this has been fixed :/ if(stats.attribs.isDirectory) { extension[0] = '\0'; @@ -2069,7 +2444,7 @@ static FileSystemNode MakeFileSystemNode(const FileStats stats, if(stats.attribs.isRemote) node.type = netDrive; if(stats.attribs.isRemovable) { - if(fileName[0] == 'A' || fileName[0] == 'B') + if(name[0] == 'A' || name[0] == 'B') node.type = floppy; else node.type = removable; @@ -2077,36 +2452,46 @@ static FileSystemNode MakeFileSystemNode(const FileStats stats, } else { - GetExtension(fileName, extension); + GetExtension(name, extension); strlwr(extension); node.type = _FileType::SelectByExtension(extension); } if(stats.attribs.isDrive && - len > 3 && !strncmp(&fileName[1], ": [", 3)) + len > 3 && !strncmp(&name[1], ": [", 3)) { - strncpy(name, fileName, 2); - name[2] = 0; - strncpy(info, &fileName[4], len - 5); + strncpy(name2, name, 2); + name2[2] = 0; + strncpy(info, &name[4], len - 5); info[len - 5] = 0; } else { - strcpy(name, fileName); + strcpy(name2, name); info[0] = 0; } - node.path = CopyString(filePath); - node.name = CopyString(name); + if(pathAddName) + { + bool isFile = stats.attribs.isFile; + bool isFolder = stats.attribs.isDirectory; + char full[MAX_LOCATION]; + strcpy(full, path); + PathCat(full, name); + node.path = full; //CopyString(full); + } + else + node.path = path; //CopyString(path); + node.name = name2; //CopyString(name2); if(info[0]) - node.info = CopyString(info); - node.extension = CopyString(extension); + node.info = info; //CopyString(info); + node.extension = extension; //CopyString(extension); if(node.type == pictureFile && previewPicture) { node.bitmap = Bitmap { alphaBlend = true }; - node.bitmap.Load(filePath, null, displaySystem); + node.bitmap.Load(path, null, displaySystem); } return node;