Records

Functions

  • std::string GetCurrentDirectory ()

    Returns the current directory. If the current directory cannot be determined,

    this function will terminate the process.

    Defined at line 22 of file ../../src/lib/files/directory.cc

  • bool IsDirectory (const std::string & path)

    Returns whether the given path is a directory.

    Defined at line 31 of file ../../src/lib/files/directory.cc

  • bool IsDirectoryAt (int root_fd, const std::string & path)

    Returns whether the given path is a directory. If |path| is relative, resolve

    it with |root_fd| as reference. See |openat(2)|.

    Defined at line 33 of file ../../src/lib/files/directory.cc

  • template <typename T>
    bool ReadFileDescriptor (int fd, T * result)

    Defined at line 33 of file ../../sdk/lib/zircon-assert/test/zircon-assert-libc-test.cc

  • std::string SimplifyPath (std::string path)

    Resolves ".." and "." components of the path syntactically without consulting

    the file system.

    Defined at line 73 of file ../../src/lib/files/path.cc

  • bool WriteFile (const std::string & path, std::string_view data)

    Writes the given data to the file at the given path. Returns true if the data

    was successfully written, otherwise returns false.

    Defined at line 66 of file ../../src/lib/files/file.cc

  • std::string AbsolutePath (const std::string & path)

    Returns the absolute path of a possibly relative path.

    It doesn't consult the filesystem or simplify the path.

    Defined at line 171 of file ../../src/lib/files/path.cc

  • bool WriteFile (const std::string & path, const char * data, ssize_t size)

    Defined at line 70 of file ../../src/lib/files/file.cc

  • bool WriteFileAt (int dirfd, const std::string & path, const char * data, ssize_t size)

    Defined at line 74 of file ../../src/lib/files/file.cc

  • std::string GetDirectoryName (const std::string & path)

    Returns the directory name component of the given path.

    Defined at line 188 of file ../../src/lib/files/path.cc

  • std::string GetBaseName (const std::string & path)

    Returns the basename component of the given path by stripping everything up

    to and including the last slash.

    Defined at line 197 of file ../../src/lib/files/path.cc

  • bool CreateDirectory (const std::string & path)

    Create a directory at the given path. If necessary, creates any intermediary

    directory.

    Defined at line 40 of file ../../src/lib/files/directory.cc

  • bool WriteFileInTwoPhases (const std::string & path, std::string_view data, const std::string & temp_root)

    Writes the given data a temporary file under |temp_root| and then moves the

    temporary file to |path|, ensuring write atomicity. Returns true if the data

    was successfully written, otherwise returns false.

    Note that |path| and |temp_root| must be within the same filesystem for the

    move to work. For example, it will not work to use |path| under /data and

    |temp_root| under /tmp.

    Defined at line 82 of file ../../src/lib/files/file.cc

  • bool CreateDirectoryAt (int root_fd, const std::string & path)

    Create a directory at the given path. If necessary, creates any intermediary

    directory. If |path| is relative, resolve it with |root_fd| as reference. See

    |openat(2)|.

    Defined at line 44 of file ../../src/lib/files/directory.cc

  • bool ReadDirContents (const std::string & path, std::vector<std::string> * out)

    List the contents of a directory. If returns false, errno will be set.

    Defined at line 72 of file ../../src/lib/files/directory.cc

  • bool IsValidName (std::string_view name)

    Returns true if |path| is a valid Fuchsia name per the fuchsia.io/Name rules:

    * It cannot be longer than [`MAX_NAME_LENGTH`] (255 bytes).

    * It cannot be empty.

    * It cannot be ".." (dot-dot).

    * It cannot be "." (single dot).

    * It cannot contain "/".

    * It cannot contain embedded NUL.

    Defined at line 204 of file ../../src/lib/files/path.cc

  • bool ReadFileToString (const std::string & path, std::string * result)

    Reads the contents of the file at the given path or file descriptor and

    stores the data in result. Returns true if the file was read successfully,

    otherwise returns false. If this function returns false, |result| will be

    the empty string.

    Defined at line 102 of file ../../src/lib/files/file.cc

  • bool ReadFileDescriptorToString (int fd, std::string * result)

    Defined at line 57 of file ../../sdk/lib/zircon-assert/test/zircon-assert-libc-test.cc

  • bool ReadDirContentsAt (int root_fd, const std::string & path, std::vector<std::string> * out)

    List the contents of a directory. If returns false, errno will be set. If |path| is relative,

    resolve it with |root_fd| as reference. See |openat(2)|.

    Defined at line 76 of file ../../src/lib/files/directory.cc

  • bool ReadFileToStringAt (int dirfd, const std::string & path, std::string * result)

    Defined at line 110 of file ../../src/lib/files/file.cc

  • bool ReadFileToVector (const std::string & path, std::vector<uint8_t> * result)

    Reads the contents of the file at the given path or file descriptor and stores the data in

    result. Returns true if the file was read successfully, otherwise returns

    false. If this function returns false, |result| will be the empty string.

    Defined at line 115 of file ../../src/lib/files/file.cc

  • bool ReadFileDescriptorToVector (int fd, std::vector<uint8_t> * result)

    Defined at line 120 of file ../../src/lib/files/file.cc

  • bool ReadFileToVectorAt (int dirfd, const std::string & path, std::vector<uint8_t> * result)

    Defined at line 124 of file ../../src/lib/files/file.cc

  • bool IsValidCanonicalPath (std::string_view path)

    Returns true if |path| is a valid Fuchsia path in canonical form per the

    fuchsia.io/Path rules:

    * It cannot be empty.

    * It cannot be longer than [`MAX_PATH_LENGTH`] (4095 bytes).

    * It cannot have a leading "/".

    * It cannot have a trailing "/".

    * Each component must be a valid name. See |IsValidName|.

    Defined at line 229 of file ../../src/lib/files/path.cc

  • bool IsFile (const std::string & path)

    Returns whether the given path is a file.

    Defined at line 129 of file ../../src/lib/files/file.cc

  • bool IsFileAt (int dirfd, const std::string & path)

    Defined at line 131 of file ../../src/lib/files/file.cc

  • bool DeletePath (const std::string & path, bool recursive)

    Delete the file or directory at the given path. If recursive is true, and

    path is a directory, also delete the directory's content.

    Defined at line 268 of file ../../src/lib/files/path.cc

  • bool GetFileSize (const std::string & path, uint64_t * size)

    If the given path is a file, set size to the size of the file.

    Defined at line 138 of file ../../src/lib/files/file.cc

  • bool GetFileSizeAt (int dirfd, const std::string & path, uint64_t * size)

    Defined at line 142 of file ../../src/lib/files/file.cc

  • bool DeletePathAt (int root_fd, const std::string & path, bool recursive)

    Delete the file or directory at the given path. If recursive is true, and

    path is a directory, also delete the directory's content. If |path| is

    relative, resolve it with |root_fd| as reference. See |openat(2)|.

    Defined at line 272 of file ../../src/lib/files/path.cc

  • std::string JoinPath (const std::string & path1const std::string & path2)

    Joins two paths together.

    Regardless if |path1| has a trailing '/' or |path2| has a leading '/', there

    will be only one '/' in-between in the joined path.

    Note that if either path is "" then the other path is returned unchanged.

    JoinPath("/foo", "bar") -> "/foo/bar"

    JoinPath("/foo", "/bar") -> "/foo/bar"

    JoinPath("/foo/", "bar") -> "/foo/bar"

    JoinPath("/foo/", "/bar") -> "/foo/bar"

    JoinPath("", "") -> ""

    JoinPath("", "/foo") -> "/foo"

    JoinPath("", "foo") -> "foo"

    JoinPath("/foo", "") -> "/foo"

    JoinPath("foo", "") -> "foo"

    JoinPath("/foo/", "") -> "/foo/"

    JoinPath("foo/", "") -> "foo/"

    Defined at line 305 of file ../../src/lib/files/path.cc