From: <ny...@us...> - 2007-02-08 16:41:54
|
Revision: 310 http://svn.sourceforge.net/pmplib/?rev=310&view=rev Author: nyaochi Date: 2007-02-08 08:41:30 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Document filepath API. Modified Paths: -------------- trunk/pmplib/include/filepath.h trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/filepath/filepath_posix.c trunk/pmplib/lib/filepath/filepath_win32.c trunk/pmplib/lib/gmi/gmi.c trunk/pmplib/lib/pmp_iriverplus2/ip2db.c trunk/pmplib/lib/pmp_iriverplus2/playlist.c trunk/pmplib/lib/pmp_iriverplus2/util.c trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c trunk/pmplib/lib/pmp_iriverplus3/util.c trunk/pmplib/lib/pmp_irivnavi/playlist.c trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c trunk/pmplib/lib/pmp_portalplayer1/util.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/include/filepath.h =================================================================== --- trunk/pmplib/include/filepath.h 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/include/filepath.h 2007-02-08 16:41:30 UTC (rev 310) @@ -24,6 +24,7 @@ #ifndef __FILEPATHUTIL_H__ #define __FILEPATHUTIL_H__ +#include <time.h> #include <ucs2char.h> #ifdef FILEPATH_EXPORTS @@ -37,56 +38,306 @@ extern "C" { #endif/*__cplusplus*/ -typedef int (*filepath_findfile_callback)( - void *instance, - const ucs2char_t* found_path, - const ucs2char_t* found_file - ); +/** + * \addtogroup filepath File/Path Manupulation API + * @{ + * + * The PMPlib File/Path Manupulation API is a utility for file-systems and + * pathnames. + */ -FILEPATHAPI int find_file( - const ucs2char_t* path, - int recursive, - filepath_findfile_callback callback, - void *instance - ); +/** + * \addtogroup filepath_string file/path string API + * @{ + * + */ +/** + * Add a (back)slash character to the end of a string. + * + * This function adds a (back)slash character to the end of the string if + * the resultant string is grammertical. If the string already has a trailing + * (back)slash, this function will not change it. + * + * @param path The pointer to the string. + * @retval ucs2char_t* Identical value to \a path argument. + */ FILEPATHAPI ucs2char_t* filepath_addslash(ucs2char_t* path); + +/** + * Remove a (back)slash character from the end of a string. + * + * This function removes a (back)slash character from the end of the string if + * the resultant string is grammertical. If the string already has no trailing + * (back)slash, this function will not change it. + * + * @param path The pointer to the string. + * @retval ucs2char_t* The identical value to \a path argument. + */ FILEPATHAPI ucs2char_t* filepath_removeslash(ucs2char_t* path); -FILEPATHAPI int filepath_hasext(const ucs2char_t* filename, const ucs2char_t* ext); - +/** + * Concatenate two strings into one well-formed path. + * + * @param dst The pointer to a buffer to receive the resultant path. + * @param size The size, in number of UCS-2 characters, of \a dst. + * @param path The pointer to a path name. + * @param file The pointer to a file name. + * @retval const ucs2char_t* The identical value to \a dst argument. + */ FILEPATHAPI const ucs2char_t* filepath_combinepath(ucs2char_t* dst, size_t size, const ucs2char_t* path, const ucs2char_t* file); +/** + * Remove the path portion of a filepath name. + * + * @param path The pointer to the filepath name from which this + * function removes the path portion. The resultant string + * will contain only the file portion. + */ FILEPATHAPI void filepath_strippath(ucs2char_t* path); -FILEPATHAPI const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root); + +/** + * Skip the path portion in a filepath name. + * + * @param path The pointer to the filepath name from which this + * function skips the path portion. The skipped string + * will contain only the file portion. + * @retval const ucs2char_t* The pointer at which the file portion begins. + */ FILEPATHAPI const ucs2char_t* filepath_skippath(const ucs2char_t* path); -FILEPATHAPI const ucs2char_t* filepath_skipdrive(const ucs2char_t* path, const ucs2char_t* root); -FILEPATHAPI const ucs2char_t* filepath_skip_one_directory(const ucs2char_t* path); +/** + * Remove the file portion from a string. + * + * @param path The pointer to the string from which the file portion + * is removed. + */ +FILEPATHAPI void filepath_remove_filespec(ucs2char_t* path); + +/** + * Skip a portion in a filepath name. + * + * @param path The pointer to the filepath name from which this + * function skips the portion. + * @param root The pointer to the string representing the portion to + * be skipped. + * @retval const ucs2char_t* The pointer at the next character after the + * portion \a root ends in \a path. + */ +FILEPATHAPI const ucs2char_t* filepath_skiproot(const ucs2char_t* path, const ucs2char_t* root); + +/** + * Skip a portion in filepath name, assuming it as the root directory. + * + * The resultant string will begin with a path character. + * + * @param path The pointer to the filepath name from which this + * function skips the portion. + * @param root The pointer to the string representing the portion to + * be skipped. + * @retval const ucs2char_t* The pointer at the next character after the + * portion \a root ends in \a path. + */ +FILEPATHAPI const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root); + +/** + * Skip a directory name in filepath name. + * + * @param path The pointer to the filepath name from which this + * function skips a directory name. + * @retval const ucs2char_t* The pointer at the next character after the + * directory name ends in \a path. + */ +FILEPATHAPI const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path); + +/** + * Add a file extension to the end of a string. + * + * @param path The pointer to the string. + * @param ext The pointer to the file extension. + */ FILEPATHAPI void filepath_add_extension(ucs2char_t* path, const ucs2char_t* ext); + +/** + * Remove a file extension from the end of a string. + * + * @param path The pointer to the string from which the extension + * is removed. + */ FILEPATHAPI void filepath_remove_extension(ucs2char_t* path); -FILEPATHAPI void filepath_remove_filespec(ucs2char_t* path); -FILEPATHAPI void filepath_replace_slash(ucs2char_t* path, ucs2char_t c); -FILEPATHAPI int filepath_is_relative(const ucs2char_t* path); +/** + * Convert a relative path to its corresponding absolute path. + * + * @param absolute The pointer to a buffer to receive the resultant path. + * @param base The name of the base directory where the relative path + * begins. + * @param relative The relative path to be converted. + * @retval int Reserved (0). + */ FILEPATHAPI int filepath_relative_to_absolute(ucs2char_t* absolute, const ucs2char_t* base, const ucs2char_t* relative); + +/** + * Canonicalize a path. + * + * @param dst The pointer to a buffer to receive the resultant path. + * @param src The path to be canonicalized. + * @retval Non-zero value if successful, zero otherwise. + */ FILEPATHAPI int filepath_path_canonicalize(ucs2char_t* dst, const ucs2char_t* src); + +/** + * Replaces all path separators with a backslash ('\') separator. + * + * This function replaces all path separators in the given path with + * Windows-style path separators (back-slashes). On POSIX systems, this means + * converting forward slash ('/') path separators into backslashes. On + * Windows, this is a no-op. The \p path is modified in place. + * + * @param path The pointer to the path string to be converted. + * @return int Reserved. + */ +FILEPATHAPI int filepath_encode(ucs2char_t* path); + +/** + * Replaces '\'-slashes in a path name with the native path separator. + * + * This function replaces all Windows-style path separators + * (back-slashes) in the given path with the native path separator. On + * POSIX systems, the replacement character is a forward slash ('/'). On + * Windows, this is a no-op. The \p path is modified in place. + * + * @param path The pointer to the path string to be converted. + * @return int Reserved. + */ +FILEPATHAPI int filepath_decode(ucs2char_t* path); + +/** @} */ + +/** + * \addtogroup filepath_filedir file/directory manupulation API + * @{ + * + */ + +/** + * Prototype for the callback function for receiving found files. + * + * @param instance The instance value. + * @param found_path The path-name portion of the found file. + * @param found_file The file-name portion of the found file. + * @retval int Reserved. + */ +typedef int (*filepath_findfile_callback)(void *instance, const ucs2char_t* found_path, const ucs2char_t* found_file); + +/** + * Find files. + * + * @param path The directory in which this function starts the search. + * @param recursive Non-zero value to search files recursively under the + * directory \p path. + * @param callback The pointer to the callback function to receive the + * names of found files. + * @param instance A user-defined instance value that will be sent to the + * callback function. + * @retval int Reserved. + */ +FILEPATHAPI int find_file(const ucs2char_t* path, int recursive, filepath_findfile_callback callback, void *instance); + +/** + * Test the existence of a file. + * + * @param path The filepath name to be tested. + * @retval int True or false. + */ FILEPATHAPI int filepath_file_exists(const ucs2char_t* path); + +/** + * Test a file name has an extension. + * + * @param filename The file name to be tested. + * @param ext The extension. + * @retval int True or false. + */ +FILEPATHAPI int filepath_hasext(const ucs2char_t* filename, const ucs2char_t* ext); + +/** + * Test if a filepath name represents a directory. + * + * @param path The filepath name to be tested. + * @retval int True or false. + */ +FILEPATHAPI int filepath_is_dir(const ucs2char_t *path); + +/** + * Test if a filepath name represents a relative path. + * + * @param path The filepath name to be tested. + * @retval int True or false. + */ +FILEPATHAPI int filepath_is_relative(const ucs2char_t* path); + +/** + * Test if two path names has a common prefix of a directory. + * + * @param path1 A filepath name. + * @param path2 Another filepath name. + * @retval int True or false. + */ FILEPATHAPI int filepath_is_same_root(const ucs2char_t* path1, const ucs2char_t* path2); +/** + * Obtain the last-modified time of a file. + * + * @param filename The filepath name. + * @retval time_t The time stamp when the file was updated most recently. + */ +FILEPATHAPI time_t filepath_mtime(const ucs2char_t *filename); + +/** + * Compares the modification times of two files. + * + * This function compares the modification times of @p file1 and @p file2 + * and returns the difference between them is returned. + * + * @param file1 The name of file #1. + * @param file2 The name of file #2. + * @retval int The comparison result: + * - < 0, if file2 was modified more recently than file1; + * - = 0, if the modification times are the same; + * - > 0, if file1 was modified more recently than file2. + */ FILEPATHAPI int filepath_compare_lastupdate(const ucs2char_t* file1, const ucs2char_t* file2); +/** + * Obtain the size of a file. + * + * @param filename The filepath name. + * @retval uint32_t The size, in bytes, of the file. + */ +FILEPATHAPI uint32_t filepath_size(const ucs2char_t *filename); + +/** + * Remove a file. + * + * @param file The name of a file to be removed. + * @retval int True if succeeded, false otherwise. + */ FILEPATHAPI int filepath_removefile(const ucs2char_t* file); + +/** + * Copy a file. + * + * @param src The name of a source file to be copied. + * @param dst The name of a destination to be created. + * @retval int True if succeeded, false otherwise. + */ FILEPATHAPI int filepath_copyfile(const ucs2char_t* src, const ucs2char_t* dst); -FILEPATHAPI int filepath_encode(ucs2char_t* path); -FILEPATHAPI int filepath_decode(ucs2char_t* path); +/** @} */ -FILEPATHAPI time_t filepath_mtime(const ucs2char_t *filename); -FILEPATHAPI uint32_t filepath_size(const ucs2char_t *filename); -FILEPATHAPI int filepath_is_dir(const ucs2char_t *filename); -FILEPATHAPI int filepath_exist(const ucs2char_t *filename); +/** @} */ #ifdef __cplusplus } Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/include/ucs2char.h 2007-02-08 16:41:30 UTC (rev 310) @@ -25,7 +25,6 @@ #define __UCS2CHAR_H__ #include <stdio.h> -#include <time.h> #ifdef UCS2_EXPORTS #define UCS2API __declspec(dllexport) Modified: trunk/pmplib/lib/filepath/filepath_posix.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/filepath/filepath_posix.c 2007-02-08 16:41:30 UTC (rev 310) @@ -23,16 +23,6 @@ /* $Id$ */ -/** - * @file - * - * Functions for working with file and path names with different path - * separators (POSIX implementation). - * - * @addtogroup filepath - * @{ - */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif/*HAVE_CONFIG_H*/ @@ -113,22 +103,6 @@ return 0; } -/** - * Finds the file name extension in a native path name. - * - * Checks if the file name in the given @p path has a file name - * extension: that is, whether the part of the path after the last - * path separator contains a period ('.'). If the @p path has an - * extension a pointer to the first character after the last period - * is returned (or a pointer to the null terminator if there are no - * subsequent characters). If the file name has no extension, then - * null itself is returned. - * - * @param path the path name to be searched for an extension. - * - * @return a pointer to the file name extension, or NULL if none was - * found. - */ static ucs2char_t* search_extension(ucs2char_t* path) { ucs2char_t* p = ucs2rchr(path, PATHCHAR); @@ -141,18 +115,6 @@ return NULL; } -/** - * Adds the native path separator to a UCS-2 encoded path name. - * - * If the given @p path does not have a native path separator at the - * end, then one is added. The @p path is modified in place, and is - * assumed to have enough space allocated to it to add the extra - * character. - * - * @param path the path name to be modified. - * - * @return a pointer to the last character in the new path. - */ ucs2char_t* filepath_addslash(ucs2char_t* path) { size_t length = ucs2len(path); @@ -166,16 +128,6 @@ return (path + length); } -/** - * Removes the native path separator from a UCS-2 encoded path name. - * - * If the given @p path has a native path separator at then end, then - * it is removed (or more accurately, it is replaced with the null - * terminator). - * - * @param path the path name to be modified. - * @return a pointer to the last character in the new path. - */ ucs2char_t* filepath_removeslash(ucs2char_t* path) { size_t length = ucs2len(path)-1; @@ -186,15 +138,6 @@ return (path + length); } -/** - * Determines if a filename has a given extension (case-insensitive). - * - * - * @param filename file name to be checked. - * @param ext file name extension to check for. - * @return non-nil if the filename has the given extension, or nil - * otherwise. - */ int filepath_hasext(const ucs2char_t* filename, const ucs2char_t* ext) { const ucs2char_t* p = search_extension((ucs2char_t*)filename); @@ -250,7 +193,7 @@ return p ? p+1 : path; } -const ucs2char_t* filepath_skipdrive(const ucs2char_t* path, const ucs2char_t* root) +const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root) { const ucs2char_t* p = filepath_skiproot(path, root); if (p == NULL) p = path; @@ -260,7 +203,7 @@ return p; } -const ucs2char_t* filepath_skip_one_directory(const ucs2char_t* path) +const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path) { ucs2char_t* p = ucs2chr(path, PATHCHAR); return p ? p+1 : NULL; @@ -293,25 +236,6 @@ } } -/** - * Replace native path separators in a path with another character. - * - * The native path separators (i.e. '/' on POSIX-like systems) in the - * given @p path are replaced with the given character, @p c. The - * path is modified in place. - * @param path the path in which path separators are to be replaced. - * @param c the replacement character. - */ -void filepath_replace_slash(ucs2char_t* path, ucs2char_t c) -{ - while (*path) { - if (*path == PATHCHAR) { - *path = c; - } - path++; - } -} - void filepath_add_extension(ucs2char_t* path, const ucs2char_t* ext) { ucs2char_t* p = search_extension(path); @@ -336,25 +260,28 @@ } } -/** - * Tests whether a path name is relative. - * - * Checks whether the given @p path begins with a path separator - * character. If the path does begin with a path separator, then it - * is absolute and nil is returned. Otherwise the path is relative, - * and a non-nil value is returned. - * - * @param path the path to be tested for being relative. - * @return non-nil if the path name is relative, nil otherwise. - */ int filepath_is_relative(const ucs2char_t* path) { return (*path != PATHCHAR); } -int filepath_file_exists(const ucs2char_t* path) +int filepath_file_exists(const ucs2char_t *path) { - return filepath_exist(path); + int ret = 0; + struct stat st; + char *mbs_path = ucs2dupmbs(filename); + + if (mbs_path) { + path_decode(mbs_path); + //fprintf(stderr, "is_exist: %s\n", mbs_path); + ret = open(mbs_path, 0); + free(mbs_path); + if (ret != -1) { + close(ret); + } + return (ret != -1); + } + return 0; } int filepath_relative_to_absolute(ucs2char_t* absolute, const ucs2char_t* base, const ucs2char_t* relative) @@ -362,34 +289,11 @@ return (rel2abs(relative, base, absolute, MAX_PATH) != NULL); } -/** - * Tests whether a path name has a given prefix. - * - * Tests whether the @p path name begins with the named @p root. If - * @p root names a directory with a trailing path separator, then this - * function is useful for checking whether a directory (or file) with - * the given @p path would be a sub-directory of (respectively, file - * located below) @p root. - * @param path the path name to be checked for a given prefix. - * @param root the prefix to check for. - * @return non-nil if the path name starts with the given @p root and - * nil otherwise. - */ int filepath_is_same_root(const ucs2char_t* path, const ucs2char_t* root) { return (ucs2ncmp(path, root, ucs2len(root)) == 0); } -/** - * Compares the modification times of two files. - * - * The modification times of @p file1 and @p file2 are compared, and - * the difference between them is returned. The result is: - * - < 0, if file2 was modified more recently than file1; - * - = 0, if the modification times are the same; - * - > 0, if file1 was modified more recently than file2. - * @return the difference in modification times between the two files. - */ int filepath_compare_lastupdate(const ucs2char_t* file1, const ucs2char_t* file2) { int ret = 0; @@ -430,20 +334,6 @@ return ret; } -/** - * Removes the named file. - * - * The given @p file name is converted to a multi-byte character - * string, which is used as an argument to the 'remove' function in - * the C library. Thus, if the @p file name refers to a file, then - * that file is unlinked. If it refers to a directory, and that - * directory is empty, then the directory is deleted. The value - * returned is the result of the calling remove, i.e. 0 on success, - * and -1 on error. The value of errno will be set in the case of an - * error. - * @param file the path name to be unlinked/deleted. - * @return 0 on success, -1 on error. - */ int filepath_removefile(const ucs2char_t* file) { int ret = 0; @@ -453,17 +343,6 @@ return ret; } -/** - * Replaces all path separators with a backslash ('\') separator. - * - * Replaces all path separators in the given path with Windows-style - * path separators (back-slashes). On POSIX systems, this means - * converting forward slash ('/') path separators into backslashes. On - * Windows, this is a no-op. The @p path is modified in place. - * - * @param path the path to be converted. - * @return - */ int filepath_encode(ucs2char_t* path) { while (*path) { @@ -475,17 +354,6 @@ return 0; } -/** - * Replaces '\'-slashes in a path name with the native path separator. - * - * Replaces all Windows-style path separators (back-slashes) in the - * given path with the native path separator. On POSIX systems, the - * replacement character is a forward slash ('/'). On Windows, this - * is a no-op. The @p path is modified in place. - * - * @param path the path to be converted. - * @return - */ int filepath_decode(ucs2char_t* path) { while (*path) { @@ -496,4 +364,3 @@ } return 0; } -/**@}*/ Modified: trunk/pmplib/lib/filepath/filepath_win32.c =================================================================== --- trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/filepath/filepath_win32.c 2007-02-08 16:41:30 UTC (rev 310) @@ -117,7 +117,7 @@ return p ? p+1 : path; } -const ucs2char_t* filepath_skipdrive(const ucs2char_t* path, const ucs2char_t* root) +const ucs2char_t* filepath_changeroot(const ucs2char_t* path, const ucs2char_t* root) { const ucs2char_t* p = filepath_skiproot(path, root); if (p == NULL) p = path; @@ -127,22 +127,12 @@ return p; } -const ucs2char_t* filepath_skip_one_directory(const ucs2char_t* path) +const ucs2char_t* filepath_skipadirectory(const ucs2char_t* path) { ucs2char_t* p = ucs2chr(path, '\\'); return p ? p+1 : NULL; } -void filepath_replace_slash(ucs2char_t* path, ucs2char_t c) -{ - while (*path) { - if (*path == '\\') { - *path = c; - } - path++; - } -} - void filepath_strippath(ucs2char_t* path) { PathStripPathW(path); Modified: trunk/pmplib/lib/gmi/gmi.c =================================================================== --- trunk/pmplib/lib/gmi/gmi.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/gmi/gmi.c 2007-02-08 16:41:30 UTC (rev 310) @@ -63,6 +63,17 @@ }; +static void replace_slash(ucs2char_t* path, ucs2char_t c) +{ + while (*path) { + if (*path == PATHCHAR) { + *path = c; + } + path++; + } +} + + static int gmi_get_from_pathname( media_info_t* info, const ucs2char_t *filename, @@ -102,28 +113,28 @@ /* Obtain genre, artist, and album values from the path if necessary. */ if (flag & GMIF_GENRE) { - q = filepath_skip_one_directory(p); + q = filepath_skipadirectory(p); if (q) { info->genre = ucs2ndup(p, (q-p) - 1); p = q; - q = filepath_skip_one_directory(p); + q = filepath_skipadirectory(p); if (q) { info->artist = ucs2ndup(p, (q-p) - 1); if (flag & GMIF_ALBUM) { info->album = ucs2dup(q); filepath_removeslash(info->album); - filepath_replace_slash(info->album, (ucs2char_t)' '); + replace_slash(info->album, (ucs2char_t)' '); } } } } else { - q = filepath_skip_one_directory(p); + q = filepath_skipadirectory(p); if (q) { info->artist = ucs2ndup(p, (q-p) - 1); if (flag & GMIF_ALBUM) { info->album = ucs2dup(q); filepath_removeslash(info->album); - filepath_replace_slash(info->album, (ucs2char_t)' '); + replace_slash(info->album, (ucs2char_t)' '); } } } Modified: trunk/pmplib/lib/pmp_iriverplus2/ip2db.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus2/ip2db.c 2007-02-08 16:41:30 UTC (rev 310) @@ -196,7 +196,7 @@ } dst->entry_number = j+1; - dst->pathname = ucs2dup(filepath_skipdrive(src->filename, path_to_root)); + dst->pathname = ucs2dup(filepath_changeroot(src->filename, path_to_root)); filepath_remove_filespec(dst->pathname); filepath_encode(dst->pathname); dst->filename = ucs2dup(filepath_skippath(src->filename)); Modified: trunk/pmplib/lib/pmp_iriverplus2/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus2/playlist.c 2007-02-08 16:41:30 UTC (rev 310) @@ -58,7 +58,7 @@ filepath_decode(decoded_filename); // 2. As above, with mount point prefix stripped. - ucs2cpy(decoded_filepathname, filepath_skipdrive(decoded_filename, path_to_root)); + ucs2cpy(decoded_filepathname, filepath_changeroot(decoded_filename, path_to_root)); // 3. As above, but with filename stripped. ucs2cpy(decoded_pathname, decoded_filepathname); Modified: trunk/pmplib/lib/pmp_iriverplus2/util.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus2/util.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus2/util.c 2007-02-08 16:41:30 UTC (rev 310) @@ -31,6 +31,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include "util.h" Modified: trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus3/pmp_iriverplus3.c 2007-02-08 16:41:30 UTC (rev 310) @@ -569,7 +569,7 @@ ip3db_variant_t* dst = records[i]; ip3db_record_init(&pmpmi->ip3db, &records[i]); - ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_skipdrive(src->filename, pmp->info.path_to_root)); + ip3db_variant_set_str(&dst[IP3DBF_MUSIC_FILEPATH], filepath_changeroot(src->filename, pmp->info.path_to_root)); filepath_remove_filespec(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_addslash(dst[IP3DBF_MUSIC_FILEPATH].value.str); filepath_slash(dst[IP3DBF_MUSIC_FILEPATH].value.str); @@ -700,7 +700,7 @@ filepath_combinepath(filepath, MAX_PATH, rootdir, music->pmp->info.path_to_playlist); filepath_addslash(filepath); - dst->filepath = ucs2dup(filepath_skipdrive(filepath, music->pmp->info.path_to_root)); + dst->filepath = ucs2dup(filepath_changeroot(filepath, music->pmp->info.path_to_root)); filepath_slash(dst->filepath); dst->num_entries = src->num_entries; @@ -708,7 +708,7 @@ for (j = 0;j < src->num_entries;++j) { ucs2char_t filename[MAX_PATH]; - ucs2cpy(filename, filepath_skipdrive(src->entries[j], music->pmp->info.path_to_root)); + ucs2cpy(filename, filepath_changeroot(src->entries[j], music->pmp->info.path_to_root)); filepath_slash(filename); dst->entries[j] = ucs2dup(filename); } Modified: trunk/pmplib/lib/pmp_iriverplus3/util.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/util.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_iriverplus3/util.c 2007-02-08 16:41:30 UTC (rev 310) @@ -28,6 +28,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include <malloc.h> Modified: trunk/pmplib/lib/pmp_irivnavi/playlist.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/playlist.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_irivnavi/playlist.c 2007-02-08 16:41:30 UTC (rev 310) @@ -63,7 +63,7 @@ if (mediafiles[i][0]) { char *mbs = NULL; ucs2char_t filename[MAX_PATH]; - ucs2cpy(filename, filepath_skipdrive(mediafiles[i], path_to_root)); + ucs2cpy(filename, filepath_changeroot(mediafiles[i], path_to_root)); filepath_encode(filename); Modified: trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c =================================================================== --- trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_irivnavi/pmp_irivnavi.c 2007-02-08 16:41:30 UTC (rev 310) @@ -474,7 +474,7 @@ // Set record fields. record_init(dst); - dst->filename = ucs2dupmbs(filepath_skipdrive(src->filename, music->pmp->info.path_to_root)); + dst->filename = ucs2dupmbs(filepath_changeroot(src->filename, music->pmp->info.path_to_root)); dst->title = src->title ? ucs2dupmbs(src->title) : ucs2dupmbs(filepath_skippath(src->filename));; dst->artist = ucs2dupmbs(src->artist ? src->artist : ucs2cs_unknown); dst->album = ucs2dupmbs(src->album ? src->album : ucs2cs_unknown); Modified: trunk/pmplib/lib/pmp_portalplayer1/util.c =================================================================== --- trunk/pmplib/lib/pmp_portalplayer1/util.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/pmp_portalplayer1/util.c 2007-02-08 16:41:30 UTC (rev 310) @@ -31,6 +31,7 @@ #include <os.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #include <ucs2char.h> #include "util.h" Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 14:19:22 UTC (rev 309) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-08 16:41:30 UTC (rev 310) @@ -319,22 +319,3 @@ } return 0; } - -int filepath_exist(const ucs2char_t *filename) -{ - int ret = 0; - struct stat st; - char *mbs_path = ucs2dupmbs(filename); - - if (mbs_path) { - path_decode(mbs_path); - //fprintf(stderr, "is_exist: %s\n", mbs_path); - ret = open(mbs_path, 0); - free(mbs_path); - if (ret != -1) { - close(ret); - } - return (ret != -1); - } - return 0; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |