1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 //--------------------------------------------------------------------- 5 /*! 6 \file storage_support.h 7 Interface declarations for miscellaneous internal 8 Storage Kit support functions. 9 */ 10 11 #ifndef _STORAGE_SUPPORT_H 12 #define _STORAGE_SUPPORT_H 13 14 #include <string> 15 16 namespace BPrivate { 17 namespace Storage { 18 19 //! Returns whether the supplied path is absolute. 20 bool is_absolute_path(const char *path); 21 22 //! splits a path name into directory path and leaf name 23 status_t split_path(const char *fullPath, char *&path, char *&leaf); 24 25 //! splits a path name into directory path and leaf name 26 status_t split_path(const char *fullPath, char **path, char **leaf); 27 28 //! Parses the first component of a path name. 29 status_t parse_first_path_component(const char *path, int32& length, 30 int32& nextComponent); 31 32 //! Parses the first component of a path name. 33 status_t parse_first_path_component(const char *path, char *&component, 34 int32& nextComponent); 35 36 //! Checks whether an entry name is a valid entry name. 37 status_t check_entry_name(const char *entry); 38 39 //! Checks whether a path name is a valid path name. 40 status_t check_path_name(const char *path); 41 42 /*! \brief Returns a copy of \c str in which all alphabetic characters 43 are lowercase. 44 45 Returns \c "(null)" if you're a bonehead and pass in a \c NULL pointer. 46 */ 47 std::string to_lower(const char *str); 48 49 /*! \brief Places a copy of \c str in \c result in which all alphabetic 50 characters are lowercase. 51 52 Returns \c "(null)" if you're a bonehead and pass in a \c NULL pointer. 53 */ 54 void to_lower(const char *str, std::string &result); 55 56 /*! \brief Copies \c str into \c result, converting any uppercase alphabetics 57 to lowercase. 58 59 \a str and \a result may point to the same string. \a result is 60 assumed to be as long as or longer than \a str. 61 */ 62 void to_lower(const char *str, char *result); 63 64 //! Converts \c str to lowercase. 65 void to_lower(char *str); 66 67 /*! \brief Escapes any whitespace or other special characters in the path 68 69 \a result must be large enough to accomodate the addition of 70 escape sequences to \a str. \a str and \a result may *NOT* point to 71 the same string. 72 73 Note that this function was designed for use with the registrar's 74 RecentEntries class, and may not create escapes exactly like you're 75 hoping. Please double check the code for the function to see if this 76 is the case. 77 */ 78 void escape_path(const char *str, char *result); 79 80 /*! \brief Escapes any whitespace or other special characters in the path 81 82 \a str must be large enough to accomodate the addition of 83 escape sequences. 84 */ 85 void escape_path(char *str); 86 87 }; // namespace Storage 88 }; // namespace BPrivate 89 90 #endif // _STORAGE_SUPPORT_H 91 92 93