Voltray Engine Docs
Loading...
Searching...
No Matches
Editor::Assets::FileOperations Class Reference

Advanced file operations for asset management. More...

#include <FileOperations.h>

Static Public Member Functions

static FileInfo GetFileInfo (const std::filesystem::path &path)
 Get detailed file information.
 
static CopyResult CopyFiles (const std::vector< std::filesystem::path > &sources, const std::filesystem::path &destination, bool overwrite=false)
 Copy files with progress tracking.
 
static CopyResult MoveFiles (const std::vector< std::filesystem::path > &sources, const std::filesystem::path &destination, bool overwrite=false)
 Move files with progress tracking.
 
static bool CreateDirectoryRecursive (const std::filesystem::path &path)
 Create directory with intermediate directories.
 
static size_t DeleteFiles (const std::vector< std::filesystem::path > &paths, bool moveToTrash=true)
 Delete files and directories safely.
 
static std::filesystem::path GenerateUniqueFilename (const std::filesystem::path &basePath)
 Generate unique filename if file already exists.
 
static std::vector< std::filesystem::path > FindFiles (const std::filesystem::path &directory, const std::string &pattern, bool recursive=false)
 Search for files matching pattern.
 
static std::string FormatFileSize (std::uintmax_t sizeBytes)
 Get file size in human-readable format.
 
static std::string FormatFileTime (const std::filesystem::file_time_type &fileTime)
 Get file modification time as string.
 
static bool HasPermission (const std::filesystem::path &path, std::filesystem::perms permission)
 Check if file has specific permissions.
 
static bool SetPermissions (const std::filesystem::path &path, std::filesystem::perms permissions)
 Set file permissions.
 
static bool IsValidFilename (const std::string &filename)
 Validate filename for current OS.
 
static std::string SanitizeFilename (const std::string &filename)
 Sanitize filename for current OS.
 
static std::string GetMimeType (const std::string &extension)
 Get MIME type for file extension.
 
static std::string GetFileCategory (const std::string &extension)
 Get file category for extension.
 
static std::uintmax_t GetDirectorySize (const std::filesystem::path &directory)
 Calculate directory size recursively.
 
static bool OpenWithDefaultApplication (const std::filesystem::path &path)
 Open file with system default application.
 
static bool ShowInFileExplorer (const std::filesystem::path &path)
 Show file in system file explorer.
 
static std::uintmax_t GetAvailableSpace (const std::filesystem::path &path)
 Get available disk space for path.
 
static bool IsNetworkPath (const std::filesystem::path &path)
 Check if path is on a network drive.
 
static std::filesystem::path CreateBackup (const std::filesystem::path &filePath)
 Backup file with timestamp.
 
static bool CompareFiles (const std::filesystem::path &file1, const std::filesystem::path &file2)
 Compare two files for equality.
 

Detailed Description

Advanced file operations for asset management.

Member Function Documentation

◆ CompareFiles()

bool Editor::Assets::FileOperations::CompareFiles ( const std::filesystem::path &  file1,
const std::filesystem::path &  file2 
)
static

Compare two files for equality.

Parameters
file1First file path
file2Second file path
Returns
True if files are identical

◆ CopyFiles()

CopyResult Editor::Assets::FileOperations::CopyFiles ( const std::vector< std::filesystem::path > &  sources,
const std::filesystem::path &  destination,
bool  overwrite = false 
)
static

Copy files with progress tracking.

Parameters
sourcesList of source files/directories
destinationDestination directory
overwriteWhether to overwrite existing files
Returns
CopyResult with operation details

◆ CreateBackup()

std::filesystem::path Editor::Assets::FileOperations::CreateBackup ( const std::filesystem::path &  filePath)
static

Backup file with timestamp.

Parameters
filePathFile to backup
Returns
Path to backup file, empty if failed

◆ CreateDirectoryRecursive()

bool Editor::Assets::FileOperations::CreateDirectoryRecursive ( const std::filesystem::path &  path)
static

Create directory with intermediate directories.

Parameters
pathDirectory path to create
Returns
True if successful

◆ DeleteFiles()

size_t Editor::Assets::FileOperations::DeleteFiles ( const std::vector< std::filesystem::path > &  paths,
bool  moveToTrash = true 
)
static

Delete files and directories safely.

Parameters
pathsList of paths to delete
moveToTrashWhether to move to recycle bin instead of permanent deletion
Returns
Number of successfully deleted items

◆ FindFiles()

std::vector< std::filesystem::path > Editor::Assets::FileOperations::FindFiles ( const std::filesystem::path &  directory,
const std::string &  pattern,
bool  recursive = false 
)
static

Search for files matching pattern.

Parameters
directoryDirectory to search in
patternSearch pattern (supports wildcards)
recursiveWhether to search subdirectories
Returns
List of matching files

◆ FormatFileSize()

std::string Editor::Assets::FileOperations::FormatFileSize ( std::uintmax_t  sizeBytes)
static

Get file size in human-readable format.

Parameters
sizeBytesSize in bytes
Returns
Formatted size string (e.g., "1.5 MB")

◆ FormatFileTime()

std::string Editor::Assets::FileOperations::FormatFileTime ( const std::filesystem::file_time_type &  fileTime)
static

Get file modification time as string.

Parameters
fileTimeFile time
Returns
Formatted time string

◆ GenerateUniqueFilename()

std::filesystem::path Editor::Assets::FileOperations::GenerateUniqueFilename ( const std::filesystem::path &  basePath)
static

Generate unique filename if file already exists.

Parameters
basePathBase file path
Returns
Unique file path

◆ GetAvailableSpace()

std::uintmax_t Editor::Assets::FileOperations::GetAvailableSpace ( const std::filesystem::path &  path)
static

Get available disk space for path.

Parameters
pathDirectory path
Returns
Available space in bytes

◆ GetDirectorySize()

std::uintmax_t Editor::Assets::FileOperations::GetDirectorySize ( const std::filesystem::path &  directory)
static

Calculate directory size recursively.

Parameters
directoryDirectory path
Returns
Total size in bytes

◆ GetFileCategory()

std::string Editor::Assets::FileOperations::GetFileCategory ( const std::string &  extension)
static

Get file category for extension.

Parameters
extensionFile extension
Returns
Category string (e.g., "Image", "Audio", "Document")

◆ GetFileInfo()

FileInfo Editor::Assets::FileOperations::GetFileInfo ( const std::filesystem::path &  path)
static

Get detailed file information.

Parameters
pathPath to the file or directory
Returns
FileInfo structure with detailed information

◆ GetMimeType()

std::string Editor::Assets::FileOperations::GetMimeType ( const std::string &  extension)
static

Get MIME type for file extension.

Parameters
extensionFile extension
Returns
MIME type string

◆ HasPermission()

bool Editor::Assets::FileOperations::HasPermission ( const std::filesystem::path &  path,
std::filesystem::perms  permission 
)
static

Check if file has specific permissions.

Parameters
pathFile path
permissionPermission to check
Returns
True if file has the permission

◆ IsNetworkPath()

bool Editor::Assets::FileOperations::IsNetworkPath ( const std::filesystem::path &  path)
static

Check if path is on a network drive.

Parameters
pathPath to check
Returns
True if on network drive

◆ IsValidFilename()

bool Editor::Assets::FileOperations::IsValidFilename ( const std::string &  filename)
static

Validate filename for current OS.

Parameters
filenameFilename to validate
Returns
True if filename is valid

◆ MoveFiles()

CopyResult Editor::Assets::FileOperations::MoveFiles ( const std::vector< std::filesystem::path > &  sources,
const std::filesystem::path &  destination,
bool  overwrite = false 
)
static

Move files with progress tracking.

Parameters
sourcesList of source files/directories
destinationDestination directory
overwriteWhether to overwrite existing files
Returns
CopyResult with operation details

◆ OpenWithDefaultApplication()

bool Editor::Assets::FileOperations::OpenWithDefaultApplication ( const std::filesystem::path &  path)
static

Open file with system default application.

Parameters
pathFile path
Returns
True if successful

◆ SanitizeFilename()

std::string Editor::Assets::FileOperations::SanitizeFilename ( const std::string &  filename)
static

Sanitize filename for current OS.

Parameters
filenameFilename to sanitize
Returns
Sanitized filename

◆ SetPermissions()

bool Editor::Assets::FileOperations::SetPermissions ( const std::filesystem::path &  path,
std::filesystem::perms  permissions 
)
static

Set file permissions.

Parameters
pathFile path
permissionsNew permissions
Returns
True if successful

◆ ShowInFileExplorer()

bool Editor::Assets::FileOperations::ShowInFileExplorer ( const std::filesystem::path &  path)
static

Show file in system file explorer.

Parameters
pathFile path
Returns
True if successful

The documentation for this class was generated from the following files: