cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
file.hpp File Reference
#include <filesystem>
#include <functional>
#include <vector>
#include <cpp-toolbox/cpp-toolbox_export.hpp>
#include "cpp-toolbox/macro.hpp"
Include dependency graph for file.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  toolbox
 
namespace  toolbox::file
 

Typedefs

using toolbox::file::file_time_type = std::filesystem::file_time_type
 
using toolbox::file::file_type = std::filesystem::file_type
 

Functions

CPP_TOOLBOX_EXPORT auto toolbox::file::string_to_path (const std::string &str) -> std::filesystem::path
 将字符串转换为文件系统路径 / Convert a string to a filesystem path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::path_to_string (const std::filesystem::path &path) -> std::string
 将文件系统路径转换为字符串 / Convert a filesystem path to a string
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_file_size (const std::filesystem::path &path) -> std::size_t
 获取文件的字节大小 / Get the size of a file in bytes
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_absolute_path (const std::filesystem::path &path) -> std::filesystem::path
 获取文件或目录的绝对路径 / Get the absolute path of a file or directory
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_relative_path (const std::filesystem::path &path, const std::filesystem::path &base) -> std::filesystem::path
 获取两个路径之间的相对路径 / Get the relative path between two paths
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_parent_path (const std::filesystem::path &path) -> std::filesystem::path
 获取路径的父目录 / Get the parent directory of a path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_file_name (const std::filesystem::path &path) -> std::string
 获取路径的文件名部分 / Get the file name component of a path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_file_extension (const std::filesystem::path &path) -> std::string
 获取路径的文件扩展名 / Get the file extension of a path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::copy_file (const std::filesystem::path &src, const std::filesystem::path &dst) -> bool
 复制文件 / Copy a file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::move_file (const std::filesystem::path &src, const std::filesystem::path &dst) -> bool
 移动文件 / Move a file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::delete_file (const std::filesystem::path &path) -> bool
 删除指定路径的文件 / Delete a file at the specified path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::file_exists (const std::filesystem::path &path) -> bool
 检查指定路径是否存在文件 / Check if a file exists at the specified path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::create_directory (const std::filesystem::path &path) -> bool
 在指定路径创建目录 / Create a directory at the specified path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::directory_exists (const std::filesystem::path &path) -> bool
 检查指定路径是否存在目录 / Check if a directory exists at the specified path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::delete_directory (const std::filesystem::path &path) -> bool
 删除指定路径的目录 / Delete a directory at the specified path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_current_directory () -> std::filesystem::path
 获取当前工作目录 / Get the current working directory
 
CPP_TOOLBOX_EXPORT auto toolbox::file::path_type (const std::filesystem::path &path) -> std::filesystem::file_type
 获取指定路径的文件系统对象类型 / Get the type of the filesystem object at the specified path
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_regular_file (const std::filesystem::path &path) -> bool
 检查路径是否为常规文件 / Check if a path is a regular file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_directory (const std::filesystem::path &path) -> bool
 检查路径是否为目录 / Check if a path is a directory
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_symlink (const std::filesystem::path &path) -> bool
 检查路径是否为符号链接 / Check if a path is a symbolic link
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_fifo (const std::filesystem::path &path) -> bool
 检查路径是否为FIFO(命名管道) / Check if a path is a FIFO (named pipe)
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_socket (const std::filesystem::path &path) -> bool
 检查路径是否为套接字 / Check if a path is a socket
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_block_file (const std::filesystem::path &path) -> bool
 检查路径是否为块设备 / Check if a path is a block device
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_character_file (const std::filesystem::path &path) -> bool
 检查路径是否为字符设备 / Check if a path is a character device
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_other (const std::filesystem::path &path) -> bool
 检查路径是否为未知类型 / Check if a path is of an unknown type
 
CPP_TOOLBOX_EXPORT auto toolbox::file::is_empty (const std::filesystem::path &path) -> bool
 检查路径是否为空 / Check if a path is empty
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_creation_time (const std::filesystem::path &path) -> file_time_type
 获取文件的创建时间 / Get the creation time of a file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_last_access_time (const std::filesystem::path &path) -> file_time_type
 获取文件的最后访问时间 / Get the last access time of a file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_last_write_time (const std::filesystem::path &path) -> file_time_type
 获取文件的最后修改时间 / Get the last write time of a file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_symlink_target (const std::filesystem::path &path) -> std::filesystem::path
 获取符号链接的目标路径 / Get the target of a symbolic link
 
CPP_TOOLBOX_EXPORT auto toolbox::file::traverse_directory (const std::filesystem::path &path) -> std::vector< std::filesystem::path >
 遍历目录 / Traverse a directory
 
CPP_TOOLBOX_EXPORT auto toolbox::file::list_files_in_directory (const std::filesystem::path &path, const std::string &extension="") -> std::vector< std::filesystem::path >
 列出目录下指定扩展名的所有文件/Lists all files in a directory with the specified extension
 
CPP_TOOLBOX_EXPORT auto toolbox::file::list_files_in_directory (const std::filesystem::path &path, const std::vector< std::string > &extensions) -> std::vector< std::filesystem::path >
 列出目录下指定多个扩展名的所有文件/Lists all files in a directory with the specified extensions
 
CPP_TOOLBOX_EXPORT auto toolbox::file::recursive_traverse_directory (const std::filesystem::path &path) -> std::vector< std::filesystem::path >
 递归遍历目录 / Recursively traverse a directory
 
CPP_TOOLBOX_EXPORT auto toolbox::file::traverse_directory_files (const std::filesystem::path &path, std::function< void(const std::filesystem::path &)> &callback) -> void
 遍历目录并为每个文件调用回调函数 / Traverse a directory and call a callback for each file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::recursive_traverse_directory_files (const std::filesystem::path &path, std::function< void(const std::filesystem::path &)> &callback) -> void
 递归遍历目录并为每个文件调用回调函数 / Recursively traverse a directory and call a callback for each file
 
CPP_TOOLBOX_EXPORT auto toolbox::file::get_current_working_directory () -> std::filesystem::path
 获取当前工作目录 / Get the current working directory