Skip to content

Commit

Permalink
fix #38
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Apr 8, 2023
1 parent 65deaed commit 195f74b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Improvements:
Fixes:

- fixed sample tune value not displaying correctly for values below -99
- fixed some directories being above ".." in file selector
- general minor visual glitch fixes

-- v0.4.4-unofficial (2023-04-07)
Expand Down
1 change: 1 addition & 0 deletions tobkit/include/tobkit/fileselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class File {
public:
std::string name;
std::string name_with_path;
u8 order;
bool is_dir;
u32 size;
};
Expand Down
16 changes: 6 additions & 10 deletions tobkit/source/fileselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,13 @@ std::string stringtolowercase(std::string str)

inline bool compare_filenames(File f1, File f2)
{
bool res;

if((f1.is_dir)&&(!f2.is_dir)) {
res = true;
} else if ((!f1.is_dir)&&(f2.is_dir)) {
res = false;
if(f1.order != f2.order) {
return f1.order < f2.order;
} else if(strcasecmp(f1.name.c_str(),f2.name.c_str())<0) {
res = true;
return true;
} else {
res = false;
return false;
}

return res;
}

// Reads the current directory
Expand Down Expand Up @@ -242,6 +236,7 @@ void FileSelector::read_directory(void)
newfile.name = direntry->d_name;
newfile.name_with_path = current_directory + direntry->d_name;
newfile.is_dir = (direntry->d_type == DT_DIR);
newfile.order = newfile.is_dir ? 1 : 2;

if(!newfile.is_dir) {
int stat_res = stat(newfile.name_with_path.c_str(), &filestats);
Expand Down Expand Up @@ -288,6 +283,7 @@ void FileSelector::read_directory(void)
File dotdot;
dotdot.name = "..";
dotdot.is_dir = true;
dotdot.order = 0;
dotdot.size = 0;
filelist.push_back(dotdot);
}
Expand Down

0 comments on commit 195f74b

Please sign in to comment.