import "ecere" import "EDE" import "ExplorerWindow" //import "Finder" //import "Search" //import "Panels" /* #ifdef __WIN32__ #include #else #include #endif */ DummyFileSystemCacheWindow dw;// { size = { 200, 200 } }; class Explorer : GuiApplication { //skin = "Acovel"; bool Init() { int c, argc = this.argc; int openArgsStartAt = 0; QuickPathTool searchPath { }; char * findWhat = null; Array comparedPaths = null; SetLoggingMode(debug, null); for(c = 1; c < argc; c++) { if(!strcmp(argv[c], "#")) { argc = c; break; } } if(argc > 1) { if(!strcmpi(argv[1], "go") && argc > 2) openArgsStartAt = 2; else if(!strcmpi(argv[1], "find") && argc > 2) { if(argv[2][0] == '\"') { findWhat = new char[strlen(argv[2])+1]; StripQuotes(argv[2], findWhat); } else findWhat = CopyString(argv[2]); if(argc > 3) { if(!strcmpi(argv[3], "in") && argc > 4) searchPath = argv[4]; else searchPath = ""; // this should make it current dir } else searchPath = ""; // same } else if(!strcmpi(argv[1], "search") && argc > 2) searchPath = argv[2]; else if(!strcmpi(argv[1], "compare") && argc > 2) { QuickPathTool goPath { }; comparedPaths = { }; if(argc == 3) { goPath = ""; // current dir comparedPaths.Add(CopyString((const char *)goPath)); // TODO: Review whether this gets freed? } for(c = 2; c < argc; c++) { const char * s; goPath = argv[c]; s = goPath; if(s) comparedPaths.Add(CopyString(s)); } if(comparedPaths.count < 2) PrintLn("compare requires at least 2 existing directories to work."); } else if(!strcmpi(argv[1], "image") && argc > 2) ; else if(!strcmpi(argv[1], "slides") && argc > 2) ; else openArgsStartAt = 1; } else openArgsStartAt = -1; if(openArgsStartAt) { QuickPathTool goPath { }; for(c = openArgsStartAt; c < argc; c++) { goPath = openArgsStartAt == -1 ? "" : argv[c]; if(goPath) { ExplorerWindow explorerWnd { }; explorerWnd.Create(); explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false); } if(openArgsStartAt == -1) break; } } else if(searchPath) { ExplorerWindow explorerWnd { }; explorerWnd.Create(); //explorerWnd.SearchLocation(searchPath); } else if(comparedPaths && comparedPaths.count > 1) { // compare /s1/library/dummies /s1/library/movies /s1/oldlib/movies "/home/redj/.gvfs/d02-2tb on kimji/library/movies" ExplorerWindow explorerWnd { }; explorerWnd.Create(); explorerWnd.view.columnsCompareStyle = true; explorerWnd.comparedLocations = comparedPaths; comparedPaths = null; // delete comparedPaths; } if(comparedPaths) { comparedPaths.Free(); delete comparedPaths; } return true; } } struct QuickPathTool { char path[MAX_LOCATION]; property const char * { set { GetWorkingDir(path, MAX_LOCATION); if(value[0] == '\"') { char * unquoted = new char[strlen(value) + 1]; StripQuotes(value, unquoted); PathCat(path, unquoted); delete unquoted; } else PathCat(path, value); if(!FileExists(path)) { // this incomplete functionality is not quite at it's place in this class int len; char * original = CopyString(path); while((len = strlen(path))) { StripLastDirectory(path, path); if(FileExists(path)) { // TODO: message location does not exist, // this higher location exists though // go there? break; } } if(!len) { // TODO: message location does not exist, // unable to select alternate location } path[0] = '\0'; delete original; } } get { return path[0] ? (char*)path : null; } } property bool { get { return path[0] != '\0'; } } }; define app = ((Explorer)__thisModule);