From f8740b3195bdff33d11d4cd23cdd791aec175c5c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 3 Oct 2015 17:11:32 +0200 Subject: Refactored Directory. --- plugingui/directory.h | 102 +++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'plugingui/directory.h') diff --git a/plugingui/directory.h b/plugingui/directory.h index 04ed3e7..a3f0059 100644 --- a/plugingui/directory.h +++ b/plugingui/directory.h @@ -24,8 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_DIRECTORY_H__ -#define __DRUMGIZMO_DIRECTORY_H__ +#pragma once #include #include @@ -38,56 +37,57 @@ #define DIRECTORY_HIDDEN 1 +namespace GUI { + class Directory { +public: + typedef struct drive { + int number; + std::string name; + } drive_t; + + typedef std::list EntryList; + typedef std::list DriveList; + + Directory(std::string path); + ~Directory(); + + std::string seperator(); + + size_t count(); + void refresh(); + std::string path(); + bool cdUp(); + bool cd(std::string dir); + bool isDir(); + void setPath(std::string path); + bool fileExists(std::string file); + + // Add filter, ie. directories or files only + EntryList entryList(); + + //void setSorting(); + + static std::string cwd(); + static std::string root(); + static std::string root(std::string path); + static std::string cleanPath(std::string path); + static Directory::EntryList listFiles(std::string path, unsigned char filter = 0); + static bool isRoot(std::string path); + static Directory::DriveList drives(); + static bool isDir(std::string path); + static bool isHidden(std::string entry); + static bool exists(std::string path); + static std::string pathDirectory(std::string filepath); + +private: + std::string _path; + EntryList _files; + DriveList _drives; - public: - typedef struct drive { - int number; - std::string name; - } drive_t; - - typedef std::list EntryList; - typedef std::list DriveList; - - Directory(std::string path); - ~Directory(); - - std::string seperator(); - - size_t count(); - void refresh(); - std::string path(); - bool cdUp(); - bool cd(std::string dir); - bool isDir(); - void setPath(std::string path); - bool fileExists(std::string file); - - // Add filter, ie. directories or files only - EntryList entryList(); - - //void setSorting(); - - static std::string cwd(); - static std::string root(); - static std::string root(std::string path); - static std::string cleanPath(std::string path); - static Directory::EntryList listFiles(std::string path, unsigned char filter = 0); - static bool isRoot(std::string path); - static Directory::DriveList drives(); - static bool isDir(std::string path); - static bool isHidden(std::string entry); - static bool exists(std::string path); - static std::string pathDirectory(std::string filepath); - - private: - std::string _path; - EntryList _files; - DriveList _drives; - - typedef std::list Path; - static Path parsePath(std::string path); - static std::string pathToStr(Path &path); + typedef std::list Path; + static Path parsePath(std::string path); + static std::string pathToStr(Path &path); }; -#endif/*__DRUMGIZMO_DIRECTORY_H__*/ +} // GUI:: -- cgit v1.2.3