Lines Matching +full:path +full:- +full:is +full:- +full:absolute
2 // Use of this source code is governed by a BSD-style license that can be
19 // Ensures a regular file owned by user |uid| and group |gid| exists at |path|.
20 // Any other entity at |path| will be deleted and replaced with an empty
21 // regular file. If a new file is needed, any missing parent directories will
26 BRILLO_EXPORT bool TouchFile(const base::FilePath& path,
35 BRILLO_EXPORT bool TouchFile(const base::FilePath& path);
37 // Opens the absolute |path| to a regular file or directory ensuring that none
38 // of the path components are symbolic links and returns a FD. If |path| is
39 // relative, or contains any symbolic links, or points to a non-regular file or
40 // directory, an invalid FD is returned instead. |mode| is ignored unless
41 // |flags| has either O_CREAT or O_TMPFILE. Note that O_CLOEXEC is set so the
45 // path - An absolute path of the file to open
46 // flags - Flags to pass to open.
47 // mode - Mode to pass to open.
48 BRILLO_EXPORT base::ScopedFD OpenSafely(const base::FilePath& path,
52 // Opens the |path| relative to the |parent_fd| to a regular file or directory
53 // ensuring that none of the path components are symbolic links and returns a
54 // FD. If |path| contains any symbolic links, or points to a non-regular file or
55 // directory, an invalid FD is returned instead. |mode| is ignored unless
56 // |flags| has either O_CREAT or O_TMPFILE. Note that O_CLOEXEC is set so the
60 // parent_fd - The file descriptor of the parent directory
61 // path - An absolute path of the file to open
62 // flags - Flags to pass to open.
63 // mode - Mode to pass to open.
65 const base::FilePath& path,
69 // Opens the absolute |path| to a FIFO ensuring that none of the path components
70 // are symbolic links and returns a FD. If |path| is relative, or contains any
71 // symbolic links, or points to a non-regular file or directory, an invalid FD
72 // is returned instead. |mode| is ignored unless |flags| has either O_CREAT or
76 // path - An absolute path of the file to open
77 // flags - Flags to pass to open.
78 // mode - Mode to pass to open.
79 BRILLO_EXPORT base::ScopedFD OpenFifoSafely(const base::FilePath& path,
83 // Iterates through the path components and creates any missing ones. Guarantees
89 // full_path - An absolute path of the directory to create and open.
93 // Writes the entirety of the given data to |path| with 0640 permissions
98 // path - Path of the file to write
99 // blob/data - blob/string/array to populate from
100 // (size - array size)
101 BRILLO_EXPORT bool WriteStringToFile(const base::FilePath& path,
103 BRILLO_EXPORT bool WriteToFile(const base::FilePath& path,
107 BRILLO_EXPORT bool WriteBlobToFile(const base::FilePath& path, const T& blob) { in WriteBlobToFile() argument
108 return WriteToFile(path, reinterpret_cast<const char*>(blob.data()), in WriteBlobToFile()
112 // Calls fdatasync() on file if data_sync is true or fsync() on directory or
113 // file when data_sync is false. Returns true on success.
116 // path - File/directory to be sync'ed
117 // is_directory - True if |path| is a directory
118 // data_sync - True if |path| does not need metadata to be synced
119 BRILLO_EXPORT bool SyncFileOrDirectory(const base::FilePath& path,
123 // Atomically writes the entirety of the given data to |path| with |mode|
131 // path - Path of the file to write
132 // blob/data - blob/array to populate from
133 // (size - array size)
134 // mode - File permission bit-pattern, eg. 0644 for rw-r--r--
135 BRILLO_EXPORT bool WriteToFileAtomic(const base::FilePath& path,
140 BRILLO_EXPORT bool WriteBlobToFileAtomic(const base::FilePath& path, in WriteBlobToFileAtomic() argument
143 return WriteToFileAtomic(path, reinterpret_cast<const char*>(blob.data()), in WriteBlobToFileAtomic()
147 // ComputeDirectoryDiskUsage() is similar to base::ComputeDirectorySize() in
149 // In another word, ComputeDirectoryDiskUsage() behaves like "du -s
150 // --apparent-size", and ComputeDirectorySize() behaves like "du -s". The
151 // primary difference is that sparse file and files on filesystem with
154 // The following behaviours of this function is guaranteed and is verified by
156 // - This function recursively processes directory down the tree, so disk space
158 // - Symbolic links will not be followed (the size of link itself is counted,
159 // the target is not)
160 // - Hidden files are counted as well.
161 // The following behaviours are not guaranteed, and it is recommended to avoid
162 // them in the field. Their current behaviour is provided for reference only:
163 // - This function doesn't care about filesystem boundaries, so it'll cross
166 // - Hard links will be treated like normal files, so they could be
167 // over-reported.
168 // - Directories that the current user doesn't have permission to list/stat will
170 // under-reported without error in the returned value.
171 // - Deduplication (should the filesystem support it) is ignored, and the result
172 // could be over-reported.
173 // - Doesn't check if |root_path| exists, a non-existent directory will results
175 // - There are no limit on the depth of file system tree, the program will crash
177 // - If the directory is modified during this function call, there's no
181 // - Non-POSIX system is not supported.
182 // - Disk space used by directory (and its subdirectories) itself is counted.
185 // root_path - The directory to compute the size for