61 Log::error(
"QtDirectory::path() must not be empty!\n");
65 std::vector<String> dir_list;
69 for (
int i = 0; i < (int)dir_list.size(); ++i)
71 dir_list[i] = dir_list[i].right(-cur_p.
length() - 1);
72 if (p.
startsWith(dir_list[i] +
'/') || p == dir_list[i])
77 cur_p = cur_p +
'/' + dir_list[i];
92 Log::error(
"QtDirectory::path() must not be empty!\n");
95 return QDir(QString(
path().toStdString().c_str())).exists();
107 Log::error(
"QtDirectory::path() must not be empty!\n");
112 QStringList subdirs = QDir(QString(p)).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
114 for (
int i = 0; i < subdirs.size(); ++i)
117 dirs_out.push_back(
path() + name +
'/');
125 std::vector<String> file_names;
127 for (
unsigned i = 0; i < file_names.size(); ++i)
132 file_list.push_back(file);
145 Log::error(
"QtDirectory::path() must not be empty!\n");
150 QStringList files = QDir(QString(p)).entryList(QDir::Files);
152 for (
int i = 0; i < files.size(); ++i)
155 files_out.push_back(
path() + name +
'/');
179 std::vector<String> dir_list;
181 for (
unsigned i = 0; i < dir_list.size(); ++i)
virtual bool setPath(const String &path)
Changes the path name of a VirtualDirectory. Must not be an empty string.
void listFilesRecursive(std::vector< String > &file_list) const
Use carefully this function, since this search the whole given file system tree.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
virtual bool exists() const
Returns true if the file exists.
ref< QtDirectory > qtSubDir(const String &subdir_name) const
Visualization Library main namespace.
static String fromStdString(const std::string &str, bool utf8=true)
Initializes the string from a std::string using fromUTF() if utf8 == true (default) otherwise uses fr...
virtual const String & path() const
int length() const
Returns the length of the string.
void listFilesRecursive_internal(std::vector< String > &file_list) const
virtual ref< QtFile > qtFile(const String &name) const
A VirtualDirectory that uses Qt's QDir.
void listSubDirs(std::vector< String > &dirs, bool append=false) const
bool empty() const
Returns true if length() == 0.
bool startsWith(const String &str) const
Returns true if a String starts with the specified String str.
A VirtualFile that uses Qt's QFile.
void listFiles(std::vector< String > &file_list, bool append=false) const
void setPath(const String &name)
Changes the path bound to a VirtualFile. Use carefully this function, you shouldn't rename a VirtualF...
The ref<> class is used to reference-count an Object.
String right(int count) const
Returns the count rightmost caracters of a String. If count is negative the function returns all but ...
std::string toStdString() const
Returns a UTF8 encoded std::string.
virtual ref< VirtualFile > file(const String &name) const
Returns the VirtualFile with the given name if any, NULL otherwise.
String translatePath(const String &p) const