|
TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
Utility functions for interacting with the file system. More...
Functions | |
| std::string | pwd () |
| Returns the current working directory. More... | |
| std::string | which (std::string const &executable) |
| Locates an executable on the system. More... | |
| void | cd (std::string const &path) |
| Change working directory. More... | |
| bool | exists (std::string const &path, int modeMask=0) |
| Checks if a filesystem entry the given path exists. More... | |
| bool | isdir (std::string const &path, int modeMask=0) |
| Checks if the given path is a directory. More... | |
| std::string | mktempd (std::string const &prefix="tmp", std::string const &tmpdir="") |
| Creates a directory at a suitable temporary location and returns its name. More... | |
| std::string | mktemp (std::string const &prefix="cherrypi.tmp", std::string const &tmpdir="") |
| Creates a file at a suitable temporary location and returns its name. More... | |
| void | touch (std::string const &path) |
| Update file access and modification times. More... | |
| void | rmrf (std::string const &path) |
| Recursively remove a file system entry. More... | |
| std::vector< std::string > | find (std::string const &path, std::string const &pattern) |
| Find files matching a pattern (non-recursively). More... | |
| std::vector< std::string > | findr (std::string const &path, std::string const &pattern) |
| Find files matching a pattern (recursively). More... | |
| std::vector< std::string > | glob (std::string const &pattern) |
| File globbing. More... | |
| std::vector< unsigned char > | md5 (std::string const &path) |
| std::string | basename (std::string const &path, std::string const &ext=std::string()) |
| Equivalent to basename(1) More... | |
| std::string | dirname (std::string const &path) |
| Equivalent to dirname(1) More... | |
| void | mkdir (std::string const &path, int mode=0777) |
| Creates a directory at the given path. More... | |
| void | mv (std::string const &source, std::string const &dest) |
| moves a file system entry. More... | |
| size_t | size (std::string const &path) |
| Get the size of the file in bytes. More... | |
| std::chrono::system_clock::time_point | mtime (std::string const &path) |
| Get the last modification time of the file. More... | |
| void | writeLines (std::string const &path, std::vector< std::string >) |
| writes data to a given path in different lines More... | |
| std::vector< std::string > | readLines (std::string const &path) |
| Reads data from a given path and splits it into separate lines. More... | |
| std::vector< std::string > | readLinesPartition (std::string const &path, int partition, int numPartitions) |
| Reads data from a given path and splits it into separate lines. More... | |
Variables | |
| char constexpr | kPathSep = '/' |
Utility functions for interacting with the file system.
These are a few simple syscall wrappers for file system interaction. The design here follows a few simple rules:
| std::string common::fsutils::basename | ( | std::string const & | path, |
| std::string const & | ext | ||
| ) |
Equivalent to basename(1)
| void common::fsutils::cd | ( | std::string const & | path | ) |
Change working directory.
| std::string common::fsutils::dirname | ( | std::string const & | path | ) |
Equivalent to dirname(1)
| bool common::fsutils::exists | ( | std::string const & | path, |
| int | modeMask = 0 |
||
| ) |
Checks if a filesystem entry the given path exists.
If modeMask is non-zero, this function also checks if it applies to the entry's permission bits.
| std::vector< std::string > common::fsutils::find | ( | std::string const & | path, |
| std::string const & | pattern | ||
| ) |
Find files matching a pattern (non-recursively).
| std::vector< std::string > common::fsutils::findr | ( | std::string const & | path, |
| std::string const & | pattern | ||
| ) |
Find files matching a pattern (recursively).
| std::vector< std::string > common::fsutils::glob | ( | std::string const & | pattern | ) |
File globbing.
| bool common::fsutils::isdir | ( | std::string const & | path, |
| int | modeMask = 0 |
||
| ) |
Checks if the given path is a directory.
If modeMask is non-zero, this function also checks if it applies to the directory's permission bits.
| std::vector< unsigned char > common::fsutils::md5 | ( | std::string const & | path | ) |
| void common::fsutils::mkdir | ( | std::string const & | path, |
| int | mode = 0777 |
||
| ) |
Creates a directory at the given path.
If required, intermediate directories will be created.
| std::string common::fsutils::mktemp | ( | std::string const & | prefix = "cherrypi.tmp", |
| std::string const & | tmpdir = "" |
||
| ) |
Creates a file at a suitable temporary location and returns its name.
Note: OSX will always use /tmp because of the long directory name sometimes causes problems...
| std::string common::fsutils::mktempd | ( | std::string const & | prefix = "tmp", |
| std::string const & | tmpdir = "" |
||
| ) |
Creates a directory at a suitable temporary location and returns its name.
Note: If tmpdir is not specified, OSX will always use /tmp because of the long directory name sometimes causes problems...
| std::chrono::system_clock::time_point common::fsutils::mtime | ( | std::string const & | path | ) |
Get the last modification time of the file.
| void common::fsutils::mv | ( | std::string const & | source, |
| std::string const & | dest | ||
| ) |
moves a file system entry.
Roughly corresponds to mv source dest
| std::string common::fsutils::pwd | ( | ) |
Returns the current working directory.
| std::vector< std::string > common::fsutils::readLines | ( | std::string const & | path | ) |
Reads data from a given path and splits it into separate lines.
| std::vector< std::string > common::fsutils::readLinesPartition | ( | std::string const & | path, |
| int | partition, | ||
| int | numPartitions | ||
| ) |
Reads data from a given path and splits it into separate lines.
This version will return a given partition of all lines. Specifically, it returns every kth line for which (k % numPartitions) == partition.
| void common::fsutils::rmrf | ( | std::string const & | path | ) |
Recursively remove a file system entry.
Roughly corresponds to rm -rf and thus also silently swallows any errors.
| size_t common::fsutils::size | ( | std::string const & | path | ) |
Get the size of the file in bytes.
| void common::fsutils::touch | ( | std::string const & | path | ) |
Update file access and modification times.
This is a simplified version of touch(1) that changes both access and modification time to "now".
| std::string common::fsutils::which | ( | std::string const & | executable | ) |
Locates an executable on the system.
| void common::fsutils::writeLines | ( | std::string const & | path, |
| std::vector< std::string > | data | ||
| ) |
writes data to a given path in different lines
| char constexpr common::fsutils::kPathSep = '/' |
1.8.11