Skip to content

Commit cdcbf8c

Browse files
author
Ravbug
committed
Don't display zero date if the project can't be found
1 parent 8f8567a commit cdcbf8c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

source/interface_derived.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,7 @@ string MainFrameDerived::GetPathFromDialog(const string& message)
450450
*/
451451
project MainFrameDerived::LoadProject(const std::filesystem::path &p_as_fs){
452452
//error if the file does not exist
453-
if (!filesystem::exists(p_as_fs)){
454-
//throw runtime_error(p_as_fs.string() + " does not exist.");
455-
}
453+
456454

457455
//the name is the final part of the path
458456
string name = p_as_fs.filename().string();
@@ -469,12 +467,16 @@ project MainFrameDerived::LoadProject(const std::filesystem::path &p_as_fs){
469467
}
470468

471469
//get the modification date
470+
string modifyDate;
472471
struct stat fileInfo {};
473-
if (stat(p_as_fs.string().c_str(), &fileInfo) != 0) {
474-
//throw runtime_error("Cannot get modification date. Ensure this program has access to "+p_as_fs.string());
472+
if (filesystem::exists(p_as_fs)) {
473+
if (stat(p_as_fs.string().c_str(), &fileInfo) == 0) {
474+
modifyDate = ctime(&fileInfo.st_mtime);
475+
}
475476
}
476477

477-
project p = {name,version,ctime(&fileInfo.st_mtime),p_as_fs,};
478+
479+
project p = {name,version,modifyDate,p_as_fs,};
478480
return p;
479481
}
480482

0 commit comments

Comments
 (0)