added qse_stradup() and related functions
coded qse_dir_change() for win32
This commit is contained in:
@ -22,12 +22,17 @@
|
||||
#define _QSE_CMN_PATH_H_
|
||||
|
||||
/** @file
|
||||
* This file provides functions for simple path name manipulation.
|
||||
* This file provides functions for path name manipulation.
|
||||
*/
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/**
|
||||
* The qse_basename() macro returns the pointer to the file name
|
||||
* segment in a path name. It maps to qse_mbsbasename() if #QSE_CHAR_IS_MCHAR
|
||||
* is defined; it maps to qse_wcsbasename() if #QSE_CHAR_IS_WCHAR is defined.
|
||||
*/
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
# define qse_basename(path) qse_mbsbasename(path)
|
||||
#else
|
||||
@ -38,26 +43,45 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The qse_mbsbasename() function returns the pointer to the file name
|
||||
* segment in a multibyte path name.
|
||||
*/
|
||||
const qse_mchar_t* qse_mbsbasename (
|
||||
const qse_mchar_t* path
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_wcsbasename() function returns the pointer to the file name
|
||||
* segment in a wide-character path name.
|
||||
*/
|
||||
const qse_wchar_t* qse_wcsbasename (
|
||||
const qse_wchar_t* path
|
||||
);
|
||||
|
||||
/*
|
||||
* The qse_canonpath() function deletes unnecessary path segments
|
||||
* from a path name 'path' and stores it to a memory buffer pointed
|
||||
* to by 'canon'. It null-terminates the canonical path in 'canon' and
|
||||
* returns the number of characters excluding the terminating null.
|
||||
* The caller must ensure that it is large enough before calling this
|
||||
* because this function does not check the size of the memory buffer.
|
||||
* Since the canonical path cannot be larger than the original path,
|
||||
* you can simply ensure this by providing a memory buffer as long as
|
||||
* the number of characters and a terminating null in the original path.
|
||||
/**
|
||||
* The qse_canonpath() function canonicalizes a path name @a path by deleting
|
||||
* unnecessary path segments from it and stores the result to a memory buffer
|
||||
* pointed to by @a canon. Canonicalization is purely performed on the path
|
||||
* name without refering to actual file systems. It null-terminates the
|
||||
* canonical path in @a canon and returns the number of characters excluding
|
||||
* the terminating null.
|
||||
*
|
||||
* @return the number of characters in the resulting canonical path.
|
||||
* @code
|
||||
* qse_char_t buf[64];
|
||||
* qse_canonpath ("/usr/local/../bin/sh", buf);
|
||||
* qse_printf (QSE_T("%s\n")); // prints /usr/bin/sh
|
||||
* @endcode
|
||||
*
|
||||
* The caller must ensure that it is large enough to hold the resulting
|
||||
* canonical path before calling because this function does not check the
|
||||
* size of the memory buffer. Since the canonical path cannot be larger
|
||||
* than the original path, you can simply ensure this by providing a memory
|
||||
* buffer as long as the number of characters and a terminating null in
|
||||
* the original path.
|
||||
*
|
||||
* @return number of characters in the resulting canonical path excluding
|
||||
* the terminating null.
|
||||
*/
|
||||
qse_size_t qse_canonpath (
|
||||
const qse_char_t* path,
|
||||
|
@ -961,6 +961,11 @@ qse_mchar_t* qse_mbsxdup2 (
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
qse_mchar_t* qse_mbsadup (
|
||||
const qse_mchar_t* str[],
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
qse_wchar_t* qse_wcsdup (
|
||||
const qse_wchar_t* str,
|
||||
qse_mmgr_t* mmgr
|
||||
@ -986,16 +991,23 @@ qse_wchar_t* qse_wcsxdup2 (
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
qse_wchar_t* qse_wcsadup (
|
||||
const qse_wchar_t* str[],
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
# define qse_strdup(s,mmgr) qse_mbsdup(s,mmgr)
|
||||
# define qse_strdup2(s1,s2,mmgr) qse_mbsdup2(s1,s2,mmgr)
|
||||
# define qse_strxdup(s,l,mmgr) qse_mbsxdup(s,l,mmgr)
|
||||
# define qse_strxdup2(s1,l1,s2,l2,mmgr) qse_mbsxdup(s1,l1,s2,l2,mmgr)
|
||||
# define qse_stradup(sa,mmgr) qse_mbsadup(sa,mmgr)
|
||||
#else
|
||||
# define qse_strdup(s,mmgr) qse_wcsdup(s,mmgr)
|
||||
# define qse_strdup2(s1,s2,mmgr) qse_wcsdup2(s1,s2,mmgr)
|
||||
# define qse_strxdup(s,l,mmgr) qse_wcsxdup(s,l,mmgr)
|
||||
# define qse_strxdup2(s1,l1,s2,l2,mmgr) qse_wcsxdup(s1,l1,s2,l2,mmgr)
|
||||
# define qse_stradup(sa,mmgr) qse_wcsadup(sa,mmgr)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
typedef struct qse_dir_ent_t qse_dir_ent_t;
|
||||
|
||||
struct qse_dir_ent_t
|
||||
{
|
||||
enum
|
||||
@ -38,8 +36,18 @@ struct qse_dir_ent_t
|
||||
QSE_DIR_ENT_BLOCK,
|
||||
QSE_DIR_ENT_LINK
|
||||
} type;
|
||||
qse_foff_t size;
|
||||
const qse_char_t* name;
|
||||
qse_foff_t size;
|
||||
qse_char_t* name;
|
||||
};
|
||||
|
||||
typedef struct qse_dir_ent_t qse_dir_ent_t;
|
||||
|
||||
struct qse_dir_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS (dir)
|
||||
qse_dir_ent_t ent;
|
||||
qse_char_t* curdir;
|
||||
void* info;
|
||||
};
|
||||
|
||||
typedef struct qse_dir_t qse_dir_t;
|
||||
@ -52,14 +60,22 @@ QSE_DEFINE_COMMON_FUNCTIONS (dir)
|
||||
|
||||
qse_dir_t* qse_dir_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize,
|
||||
const qse_char_t* name
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
void qse_dir_close (
|
||||
qse_dir_t* dir
|
||||
);
|
||||
|
||||
int qse_dir_init (
|
||||
qse_dir_t* dir,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_dir_fini (
|
||||
qse_dir_t* dir
|
||||
);
|
||||
|
||||
qse_dir_ent_t* qse_dir_read (
|
||||
qse_dir_t* dir
|
||||
);
|
||||
|
Reference in New Issue
Block a user