Moved C++ tools out
This commit is contained in:
60
archive/dawntools/util/Directory.hpp
Normal file
60
archive/dawntools/util/Directory.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "util/File.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
namespace Dawn {
|
||||
enum DirectoryChildType {
|
||||
DIRECTORY_CHILD_TYPE_FILE,
|
||||
DIRECTORY_CHILD_TYPE_DIRECTORY
|
||||
};
|
||||
|
||||
class Directory {
|
||||
public:
|
||||
std::string filename;
|
||||
std::filesystem::directory_iterator handle;
|
||||
|
||||
Directory(std::string dir);
|
||||
|
||||
/**
|
||||
* Opens a connection to the directory.
|
||||
* @return True if success, otherwise for failure.
|
||||
*/
|
||||
bool_t open();
|
||||
|
||||
/**
|
||||
* Returns if the directory is open.
|
||||
* @return True if open, otherwise false.
|
||||
*/
|
||||
bool_t isOpen();
|
||||
|
||||
/**
|
||||
* Closes the directory.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Returns if the directory exists.
|
||||
* @return True if exists, otherwise false.
|
||||
*/
|
||||
bool_t exists();
|
||||
|
||||
/**
|
||||
* Creates the directory and all parent directories.
|
||||
*/
|
||||
void mkdirp();
|
||||
|
||||
/**
|
||||
* Reads the directory and returns a list of files.
|
||||
*
|
||||
* @return List of filenames/directories within this directory.
|
||||
*/
|
||||
std::map<std::string, enum DirectoryChildType> readDirectory();
|
||||
|
||||
~Directory();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user