Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show double dots for root directory. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions fileLister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ const bool CFileLister::list(const std::string &p_path)
// Sort lists
sort(m_listFiles.begin(), m_listFiles.end(), compareNoCase);
sort(m_listDirs.begin(), m_listDirs.end(), compareNoCase);
// Add "..", always at the first place
m_listDirs.insert(m_listDirs.begin(), T_FILE("..", 0));

// Add "..", always at the first place except root directory
if (!File_utils::pathIsRoot(p_path))
{
m_listDirs.insert(m_listDirs.begin(), T_FILE("..", 0));
}

return true;
}

Expand Down
7 changes: 7 additions & 0 deletions fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ namespace File_utils
void diskInfo(void);

void diskUsed(const std::vector<std::string> &p_files);

// Inline functions.

inline const bool pathIsRoot(const std::string& path)
{
return path == "/";
}
}

#endif