Revert "Fixes to run the new Explorer on Windows"
[ede] / newexplorer / src / Explorer.ec
1 import "ecere"
2 import "EDE"
3 import "ExplorerWindow"
4
5 class Explorer : GuiApplication
6 {
7    bool Init()
8    {
9       QuickPathTool goPath { };
10       QuickPathTool searchPath { };
11       char * findWhat = null;
12       SetLoggingMode(debug, null);
13       if(argc > 1)
14       {
15          if(!strcmpi(argv[1], "go") && argc > 2)
16             goPath = argv[2];
17          else if(!strcmpi(argv[1], "find") && argc > 2)
18          {
19             char * unquoted;
20             if(argv[2][0] == '\"')
21                StripQuotes(argv[2], unquoted);
22             else
23                unquoted = argv[2];
24             findWhat = CopyString(unquoted);
25             if(argc > 3)
26             {
27                if(!strcmpi(argv[3], "in") && argc > 4)
28                   searchPath = argv[4];
29                else
30                   searchPath = ""; // this should make it current dir
31             }
32             else
33                searchPath = ""; // same
34          } 
35          else if(!strcmpi(argv[1], "search") && argc > 2)
36             searchPath = argv[2];
37          else if(!strcmpi(argv[1], "image") && argc > 2)
38             ;
39          else if(!strcmpi(argv[1], "slides") && argc > 2)
40             ;
41          else
42             goPath = argv[1];
43       }
44       else
45          goPath = "";
46       if(goPath)
47       {
48          ExplorerWindow explorerWnd { };
49          explorerWnd.Create();
50          //explorerWnd.GoToLocation(goPath);
51       }
52       else if(searchPath)
53       {
54          ExplorerWindow explorerWnd { };
55          explorerWnd.Create();
56          //explorerWnd.SearchLocation(searchPath);
57       }
58       return true;
59    }
60 }
61
62 struct QuickPathTool
63 {
64    char path[MAX_LOCATION];
65
66    property char * 
67    {
68       set
69       {
70          char * unquoted;
71          GetWorkingDir(path, MAX_LOCATION);
72          if(value[0] == '\"')
73             StripQuotes(value, unquoted);
74          else
75             unquoted = value;
76          PathCat(path, unquoted);
77          if(!FileExists(path))
78          {
79             // this incomplete functionality is not quite at it's place in this class
80             int len;
81             char * original = CopyString(path);
82             while((len = strlen(path)))
83             {
84                StripLastDirectory(path, path);
85                if(FileExists(path))
86                {
87                   // TODO: message location does not exist, 
88                   //       this higher location exists though
89                   //       go there?
90                   break;
91                }
92             }
93             if(!len)
94             {
95                // TODO: message location does not exist, 
96                //       unable to select alternate location
97             }
98             path[0] = '\0';
99             delete original;
100          }
101       }
102       get { return path[0] ? path : null; }
103    }
104    property bool { get { return (bool)path[0]; } }
105 };
106
107 define app = ((Explorer)__thisModule);