init
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include "defines.h"
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
namespace FS {
|
||||
class FS_API Files
|
||||
{
|
||||
public:
|
||||
static FILE* open(const char* file, const char* mode);
|
||||
static FILE* popen(const char* file, const char* mode);
|
||||
static void openOFStream(std::ofstream& stream, const char* file, std::ios_base::openmode mode = std::ios_base::out);
|
||||
static void openIFStream(std::ifstream& stream, const char* file, std::ios_base::openmode mode = std::ios_base::in);
|
||||
static void openFStream(std::fstream& stream, const char* file, std::ios_base::openmode mode);
|
||||
|
||||
static bool equals(const char* pFile1, const char* pFile2);
|
||||
static bool fileExists(const char* pathToCheck);
|
||||
static bool directoryExists(const char* pathToCheck);
|
||||
// Creates all components of a path to the filesystem
|
||||
static bool createPath(const char* path);
|
||||
// Creates all components of a path to the filesystem except the last part (i.e. for paths including a filename in the end)
|
||||
static bool createParentPath(const char* path);
|
||||
// Returns a path omitting the last part of it (essentially boost::filesystem::parent_path). Output sParentPath needs to be pre-allocated.
|
||||
static bool getParentPath(const char* path, char* parentPath);
|
||||
static bool getParentPath(const char* path, char* parentPath, size_t size);
|
||||
|
||||
/**
|
||||
* \brief Fills filename as a component of a path
|
||||
* \param path [in]: input path
|
||||
* \param filename [out]: file name, needs to be pre-allocated
|
||||
*
|
||||
* (essentially boost::filesystem::filename)
|
||||
* \return Success status
|
||||
*/
|
||||
static bool getFilename(const char* path, char* filename);
|
||||
static bool getFilename(const char* path, char* filename, size_t size);
|
||||
|
||||
/**
|
||||
* \brief Fills filename as a component of a path without the extension
|
||||
* \param path [in]: input path
|
||||
* \param filename [out]: file name without extension, needs to be pre-allocated
|
||||
*
|
||||
* (essentially boost::filesystem::filename)
|
||||
* \return Success status
|
||||
*/
|
||||
static bool getFilenameWithoutExtension(const char* path, char* filename);
|
||||
static bool getFilenameWithoutExtension(const char* path, char* filename, size_t size);
|
||||
// Returns the extension component of a path
|
||||
static bool getFilenameExtension(const char* path, char* fileNameExtension);
|
||||
static bool getFilenameExtension(const char* path, char* extension, size_t size);
|
||||
|
||||
static bool copyFile(const char* srcFile, const char* dstPath);
|
||||
static bool copyDirectory(const char* srcDir, const char* dstDir);
|
||||
|
||||
static bool remove(const char* path);
|
||||
static bool removeAll(const char* path);
|
||||
private:
|
||||
|
||||
Files() = delete;
|
||||
};
|
||||
} // namespace FS
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include "defines.h"
|
||||
#include <cinttypes>
|
||||
#include <cstdlib> // size_t for unix
|
||||
|
||||
namespace FS {
|
||||
class IEntryEnumeratorCallBack;
|
||||
|
||||
class FS_API IEntryEnumerator
|
||||
{
|
||||
public:
|
||||
|
||||
class FS_API IAttributes
|
||||
{
|
||||
public:
|
||||
virtual bool isFile() = 0;
|
||||
virtual bool isDirectory() = 0;
|
||||
virtual bool isSymbolicLink() = 0;
|
||||
|
||||
virtual bool isArchive() = 0;
|
||||
virtual bool isReadOnly() = 0;
|
||||
virtual bool isHidden() = 0;
|
||||
virtual bool isSystem() = 0;
|
||||
virtual bool isExecutable() = 0;
|
||||
|
||||
virtual size_t getSize() = 0;
|
||||
protected:
|
||||
virtual ~IAttributes() {}
|
||||
};
|
||||
|
||||
class FS_API IEntry
|
||||
{
|
||||
public:
|
||||
virtual const char* getName() = 0;
|
||||
protected:
|
||||
virtual ~IEntry() {}
|
||||
};
|
||||
|
||||
virtual bool enumerate(const char* sWildcard, bool bRecursive = false) = 0;
|
||||
virtual void release() = 0;
|
||||
protected:
|
||||
virtual ~IEntryEnumerator() { }
|
||||
};
|
||||
|
||||
class FS_API IEntryEnumeratorCallBack
|
||||
{
|
||||
public:
|
||||
virtual bool callback(IEntryEnumerator::IEntry& rEntry, IEntryEnumerator::IAttributes& rAttributes) = 0;
|
||||
virtual ~IEntryEnumeratorCallBack() { }
|
||||
};
|
||||
|
||||
extern FS_API IEntryEnumerator* createEntryEnumerator(IEntryEnumeratorCallBack& rCallBack);
|
||||
} // namespace FS
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <ov_common_defines.h>
|
||||
|
||||
#if defined FS_Shared
|
||||
# if defined TARGET_OS_Windows
|
||||
# define FS_API_Export __declspec(dllexport)
|
||||
# define FS_API_Import __declspec(dllimport)
|
||||
# elif defined TARGET_OS_Linux || defined TARGET_OS_MacOS
|
||||
# define FS_API_Export __attribute__((visibility("default")))
|
||||
# define FS_API_Import __attribute__((visibility("default")))
|
||||
# else
|
||||
# define FS_API_Export
|
||||
# define FS_API_Import
|
||||
# endif
|
||||
#else
|
||||
# define FS_API_Export
|
||||
# define FS_API_Import
|
||||
#endif
|
||||
|
||||
#if defined FS_Exports
|
||||
# define FS_API FS_API_Export
|
||||
#else
|
||||
# define FS_API FS_API_Import
|
||||
#endif
|
||||
Reference in New Issue
Block a user