aboutsummaryrefslogtreecommitdiffstats
path: root/android/utils/path.h
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:30 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:30 -0800
commitee2298a313b6e425d6ff0324be6a313b1cd9a399 (patch)
treee23c2549bfe9c14afbabe8cc2afa1da5218b540b /android/utils/path.h
parentd944e7a273e10cb40d795bdc25503b97ee60ae66 (diff)
downloadexternal_qemu-ee2298a313b6e425d6ff0324be6a313b1cd9a399.zip
external_qemu-ee2298a313b6e425d6ff0324be6a313b1cd9a399.tar.gz
external_qemu-ee2298a313b6e425d6ff0324be6a313b1cd9a399.tar.bz2
auto import from //depot/cupcake/@137055
Diffstat (limited to 'android/utils/path.h')
-rw-r--r--android/utils/path.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/android/utils/path.h b/android/utils/path.h
index 10436c6..e822834 100644
--- a/android/utils/path.h
+++ b/android/utils/path.h
@@ -55,6 +55,9 @@ extern ABool path_is_regular( const char* path );
/* checks that a path points to a directory */
extern ABool path_is_dir( const char* path );
+/* checks that a path is absolute or not */
+extern ABool path_is_absolute( const char* path );
+
/* checks that one can read/write a given (regular) file */
extern ABool path_can_read( const char* path );
extern ABool path_can_write( const char* path );
@@ -77,6 +80,33 @@ extern APosixStatus path_get_size( const char* path, uint64_t *psize );
*/
extern char* path_parent( const char* path, int levels );
+/* split a path into a (dirname,basename) pair. the result strings must be freed
+ * by the caller. Return 0 on success, or -1 on error. Error conditions include
+ * the following:
+ * - 'path' is empty
+ * - 'path' is "/" or degenerate cases like "////"
+ * - basename is "." or ".."
+ *
+ * if there is no directory separator in path, *dirname will be set to "."
+ * if the path is of type "/foo", then *dirname will be set to "/"
+ *
+ * pdirname can be NULL if you don't want the directory name
+ * pbasename can be NULL if you don't want the base name
+ */
+extern int path_split( const char* path, char* *pdirname, char* *pbasename );
+
+/* a convenience function to retrieve the directory name as returned by
+ * path_split(). Returns NULL if path_split() returns an error.
+ * the result string must be freed by the caller
+ */
+extern char* path_dirname( const char* path );
+
+/* a convenience function to retrieve the base name as returned by
+ * path_split(). Returns NULL if path_split() returns an error.
+ * the result must be freed by the caller.
+ */
+extern char* path_basename( const char* path );
+
/** OTHER FILE UTILITIES
**
** path_empty_file() creates an empty file at a given path location.