Skip to content

Commit

Permalink
Merge pull request #24 from nathanhi/master
Browse files Browse the repository at this point in the history
Output 8DOT3 short filenames whenever possible
  • Loading branch information
Gregwar authored Apr 20, 2020
2 parents b923172 + d2e2b6d commit 98e1cd5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
27 changes: 16 additions & 11 deletions src/core/FatEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,27 @@ string FatEntry::getFilename()
if (longName != "") {
return longName;
} else {
string name;
string ext = trim(shortName.substr(8,3));
string base = trim(shortName.substr(0,8));
return getShortFilename();
}
}

if (isErased()) {
base = base.substr(1);
}
string FatEntry::getShortFilename()
{
string name;
string ext = trim(shortName.substr(8,3));
string base = trim(shortName.substr(0,8));

name = base;
if (isErased()) {
base = base.substr(1);
}

if (ext != "") {
name += "." + ext;
}
name = base;

return name;
if (ext != "") {
name += "." + ext;
}

return name;
}

bool FatEntry::isDirectory()
Expand Down
1 change: 1 addition & 0 deletions src/core/FatEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class FatEntry
FatEntry();

string getFilename();
string getShortFilename();
bool isDirectory();
bool isHidden();
bool isErased();
Expand Down
9 changes: 8 additions & 1 deletion src/core/FatSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ void FatSystem::list(vector<FatEntry> &entries)
}

string name = entry.getFilename();
string shrtname = entry.getShortFilename();

cout << "\"EditDate\":\"" << entry.changeDate.isoFormat() << "\",";
cout << "\"Name\":\"" << name << "\",";
cout << "\"8DOT3Name\":\"" << shrtname << "\",";
cout << "\"Cluster\":" << entry.cluster << ",";

if (!entry.isDirectory()) {
Expand Down Expand Up @@ -557,8 +559,13 @@ void FatSystem::list(vector<FatEntry> &entries)
name += "/";
}

string shrtname = entry.getShortFilename();
if (name.compare(shrtname)) {
name += " (" + shrtname + ")";
}

printf(" %s ", entry.changeDate.pretty().c_str());
printf(" %-30s", name.c_str());
printf(" %-50s", name.c_str());

printf(" c=%u", entry.cluster);

Expand Down

0 comments on commit 98e1cd5

Please sign in to comment.