2 * Copyright 2002-2006, Haiku Inc.
3 * Distributed under the terms of the MIT License.
8 #ifndef _STORAGE_SUPPORT_H
9 #define _STORAGE_SUPPORT_H
12 \file storage_support.h
13 Interface declarations for miscellaneous internal
14 Storage Kit support functions.
17 #include <StorageDefs.h>
18 #include <SupportDefs.h>
28 struct LongDirEntry
: dirent
{ char _buffer
[B_FILE_NAME_LENGTH
]; };
30 //! Returns whether the supplied path is absolute.
31 bool is_absolute_path(const char *path
);
33 status_t
parse_path(const char *fullPath
, int &dirEnd
, int &leafStart
,
35 status_t
parse_path(const char *fullPath
, char *dirPath
, char *leaf
);
37 //! splits a path name into directory path and leaf name
38 status_t
split_path(const char *fullPath
, char *&path
, char *&leaf
);
40 //! splits a path name into directory path and leaf name
41 status_t
split_path(const char *fullPath
, char **path
, char **leaf
);
43 //! Parses the first component of a path name.
44 status_t
parse_first_path_component(const char *path
, int32
& length
,
45 int32
& nextComponent
);
47 //! Parses the first component of a path name.
48 status_t
parse_first_path_component(const char *path
, char *&component
,
49 int32
& nextComponent
);
51 //! Checks whether an entry name is a valid entry name.
52 status_t
check_entry_name(const char *entry
);
54 //! Checks whether a path name is a valid path name.
55 status_t
check_path_name(const char *path
);
57 /*! \brief Returns a copy of \c str in which all alphabetic characters
60 Returns \c "(null)" if you're a bonehead and pass in a \c NULL pointer.
62 std::string
to_lower(const char *str
);
64 /*! \brief Places a copy of \c str in \c result in which all alphabetic
65 characters are lowercase.
67 Returns \c "(null)" if you're a bonehead and pass in a \c NULL pointer.
69 void to_lower(const char *str
, std::string
&result
);
71 /*! \brief Copies \c str into \c result, converting any uppercase alphabetics
74 \a str and \a result may point to the same string. \a result is
75 assumed to be as long as or longer than \a str.
77 void to_lower(const char *str
, char *result
);
79 //! Converts \c str to lowercase.
80 void to_lower(char *str
);
82 /*! \brief Escapes any whitespace or other special characters in the path
84 \a result must be large enough to accomodate the addition of
85 escape sequences to \a str. \a str and \a result may *NOT* point to
88 Note that this function was designed for use with the registrar's
89 RecentEntries class, and may not create escapes exactly like you're
90 hoping. Please double check the code for the function to see if this
93 void escape_path(const char *str
, char *result
);
95 /*! \brief Escapes any whitespace or other special characters in the path
97 \a str must be large enough to accomodate the addition of
100 void escape_path(char *str
);
102 /*! \brief Returns whether the supplied device ID refers to the root FS.
104 bool device_is_root_device(dev_t device
);
125 // implemented in the source file to not expose syscalls to the unit tests
126 // which include this file too
146 }; // namespace Storage
147 }; // namespace BPrivate
149 using BPrivate::Storage::FDCloser
;
151 #endif // _STORAGE_SUPPORT_H