void VFSNode::mkdirs() const { // If this directory already exists, we are done. if (this->exists()) return; // Create the parent directory (and its parents etc.) if necessary. VFSNode parentNode; this->getParentNode(parentNode); if (! parentNode.getPath().isEmpty()) // root or parent of supplied path must be assumed to exist parentNode.mkdirs(); // Create this directory specifically. this->mkdir(); }
// static void VFSNode::copyDirectory(const VFSNode& source, const VFSNode& dest, bool recursive) { if (recursive) { VString sourcePathWithTrailingSeparator = source.getPath() + (source.getPath().endsWith(PATH_SEPARATOR_CHAR) ? "" : PATH_SEPARATOR_CHARS); if (dest.getPath().startsWith(sourcePathWithTrailingSeparator)) { throw VException(VSTRING_FORMAT("Attempt to recursively copy '%s' into '%s'.", source.getPath().chars(), dest.getPath().chars())); } } if (!dest.exists()) { dest.mkdirs(); } VFSNodeCopyDirectoryCallback copyDirectoryCallback(dest, recursive); source.iterate(copyDirectoryCallback); }