Skip to content

Commit d3e9a26

Browse files
committed
Fix exception setting up directories on Windows
When on a network directory, on WIndows, UtilityFunctions::fs_relative would throw, preventing app from starting.
1 parent e6402df commit d3e9a26

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

.gitignore

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
data/sandia.decay.xml
33
InterSpec/InterSpec.entitlements
44
#target/ios/InterSpec/InterSpec.xcodeproj
5-
target/electron/app/node_modules
6-
target/electron/app/data
7-
target/electron/app/InterSpec_resources
8-
target/electron/app/example_spectra
9-
target/electron/app/resources
10-
target/electron/app/release-builds
115
target/ios/boost*
126
target/ios/prefix
137
target/ios/wt
@@ -20,9 +14,13 @@ target/ios/libs
2014
.cproject
2115
.project
2216
.svnignore
17+
.bin
2318
XcodeFiles
19+
node_modules
2420
build
2521
build_*
22+
release-builds*
23+
package-lock.json
2624
documentation
2725
testing
2826
README.txt
@@ -56,4 +54,5 @@ xcuserdata/
5654
*.hmap
5755
*.ipa
5856
*.dSYM.zip
59-
*.dSYM
57+
*.dSYM
58+
target/electron/node_modules/.bin/asar

target/electron/ElectronUtils.cpp

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,25 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
107107
//Using a relative path should get us in less trouble than an absolute path
108108
// on Windows. Although havent yet tested (20190902) with network drives and such on Windows.
109109
//Should check if basedir is a relative or absolut path before this next step
110-
#warning "Need to check out how this setting basedir for Electron tartget works on WIndows network drives and such"
111-
112-
const string cwd = UtilityFunctions::get_working_path();
113-
string relbasedir = UtilityFunctions::fs_relative( cwd, basedir );
114-
cerr << "cwd='" << cwd << "'" << endl;
115-
cerr << "relbasedir='" << relbasedir << "'" << endl;
116-
cerr << "userdatadir='" << userdatadir << "'" << endl;
117-
if( relbasedir.size() >= strlen(basedir) )
118-
relbasedir = basedir;
119-
if( relbasedir.empty() )
120-
relbasedir = ".";
121-
110+
//#warning "Need to check out how this setting basedir for Electron tartget works on WIndows network drives and such"
111+
string cwd, relbasedir;
112+
113+
try
114+
{
115+
cwd = UtilityFunctions::get_working_path();
116+
relbasedir = basedir; //UtilityFunctions::fs_relative( cwd, basedir );
117+
cerr << "cwd='" << cwd << "'" << endl;
118+
cerr << "relbasedir='" << relbasedir << "'" << endl;
119+
cerr << "userdatadir='" << userdatadir << "'" << endl;
120+
//if( relbasedir.size() >= strlen(basedir) )
121+
// relbasedir = basedir;
122+
if( relbasedir.empty() )
123+
relbasedir = ".";
124+
}catch( std::exception &e )
125+
{
126+
cerr << "When setting directories to serve, caught: " << e.what() << endl;
127+
return -1;
128+
}
122129

123130
try
124131
{
@@ -129,7 +136,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
129136
}catch( std::exception &e )
130137
{
131138
cerr << e.what() << endl;
132-
return -1;
139+
return -2;
133140
}
134141

135142
try
@@ -142,7 +149,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
142149
}catch( std::exception &e )
143150
{
144151
cerr << e.what() << endl;
145-
return -2;
152+
return -3;
146153
}
147154

148155
try
@@ -153,7 +160,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
153160
}catch( std::exception &e )
154161
{
155162
cerr << e.what() << endl;
156-
return -3;
163+
return -4;
157164
}
158165

159166

@@ -166,7 +173,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
166173
}catch( std::exception &e )
167174
{
168175
cerr << e.what() << endl;
169-
return -4;
176+
return -5;
170177
}
171178

172179
try
@@ -176,7 +183,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
176183
}catch( std::exception &e )
177184
{
178185
cerr << e.what() << endl;
179-
return -5;
186+
return -6;
180187
}
181188

182189
try
@@ -187,7 +194,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
187194
}catch( std::exception &e )
188195
{
189196
cerr << e.what() << endl;
190-
return -6;
197+
return -7;
191198
}
192199

193200
try
@@ -196,7 +203,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
196203
}catch( std::exception &e )
197204
{
198205
cerr << e.what() << endl;
199-
return -7;
206+
return -8;
200207
}
201208
//ToDo: should look into using '--approot' Wt Argument.
202209

@@ -216,7 +223,7 @@ int interspec_start_server( const char *process_name, const char *userdatadir,
216223
{
217224
std::cerr << "\n\nCaught exception trying to start InterSpec server:\n\t"
218225
<< e.what() << std::endl << std::endl;
219-
return -8;
226+
return -9;
220227
}
221228

222229
return InterSpecServer::portBeingServedOn();

0 commit comments

Comments
 (0)