2012-11-09 17:31:33 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2014-11-19 14:42:24 +00:00
|
|
|
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2012-11-09 17:31:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _QSE_DIR_H_
|
|
|
|
#define _QSE_DIR_H_
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
* This file provides functions and data types for I/O multiplexing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qse/types.h>
|
|
|
|
#include <qse/macros.h>
|
|
|
|
#include <qse/cmn/time.h>
|
|
|
|
|
|
|
|
typedef struct qse_dir_t qse_dir_t;
|
|
|
|
typedef struct qse_dir_ent_t qse_dir_ent_t;
|
|
|
|
|
|
|
|
enum qse_dir_errnum_t
|
|
|
|
{
|
2012-12-27 14:40:58 +00:00
|
|
|
QSE_DIR_ENOERR = 0, /**< no error */
|
|
|
|
QSE_DIR_EOTHER, /**< other error */
|
|
|
|
QSE_DIR_ENOIMPL, /**< not implemented */
|
|
|
|
QSE_DIR_ESYSERR, /**< subsystem(system call) error */
|
|
|
|
QSE_DIR_EINTERN, /**< internal error */
|
|
|
|
|
|
|
|
QSE_DIR_ENOMEM, /**< out of memory */
|
|
|
|
QSE_DIR_EINVAL, /**< invalid parameter */
|
|
|
|
QSE_DIR_EACCES, /**< access denied */
|
|
|
|
QSE_DIR_ENOENT, /**< no such file */
|
|
|
|
QSE_DIR_EEXIST, /**< already exist */
|
|
|
|
QSE_DIR_EINTR, /**< interrupted */
|
|
|
|
QSE_DIR_EPIPE, /**< broken pipe */
|
|
|
|
QSE_DIR_EAGAIN /**< resource not available temporarily */
|
2012-11-09 17:31:33 +00:00
|
|
|
};
|
|
|
|
typedef enum qse_dir_errnum_t qse_dir_errnum_t;
|
|
|
|
|
|
|
|
enum qse_dir_flag_t
|
|
|
|
{
|
2014-12-09 13:41:58 +00:00
|
|
|
QSE_DIR_MBSPATH = (1 << 0),
|
2014-12-11 16:03:58 +00:00
|
|
|
QSE_DIR_WCSPATH = (1 << 1),
|
|
|
|
QSE_DIR_SORT = (1 << 2),
|
|
|
|
QSE_DIR_SKIPSPCDIR = (1 << 3) /**< limited to normal entries excluding . and .. */
|
2012-11-09 17:31:33 +00:00
|
|
|
};
|
2014-12-09 13:41:58 +00:00
|
|
|
typedef enum qse_dir_flag_t qse_dir_flag_t;
|
2012-11-09 17:31:33 +00:00
|
|
|
|
|
|
|
struct qse_dir_ent_t
|
|
|
|
{
|
|
|
|
const qse_char_t* name;
|
|
|
|
};
|
|
|
|
|
2014-11-14 02:44:20 +00:00
|
|
|
#if defined(__cplusplus)
|
2012-11-09 17:31:33 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-11-29 14:03:59 +00:00
|
|
|
QSE_EXPORT qse_dir_t* qse_dir_open (
|
2012-11-09 17:31:33 +00:00
|
|
|
qse_mmgr_t* mmgr,
|
|
|
|
qse_size_t xtnsize,
|
|
|
|
const qse_char_t* path,
|
2012-12-25 14:10:02 +00:00
|
|
|
int flags,
|
|
|
|
qse_dir_errnum_t* errnum /** error number */
|
2012-11-09 17:31:33 +00:00
|
|
|
);
|
|
|
|
|
2012-11-29 14:03:59 +00:00
|
|
|
QSE_EXPORT void qse_dir_close (
|
2012-11-09 17:31:33 +00:00
|
|
|
qse_dir_t* dir
|
|
|
|
);
|
|
|
|
|
2012-11-29 14:03:59 +00:00
|
|
|
QSE_EXPORT qse_mmgr_t* qse_dir_getmmgr (
|
2012-11-09 17:31:33 +00:00
|
|
|
qse_dir_t* dir
|
|
|
|
);
|
|
|
|
|
2012-11-29 14:03:59 +00:00
|
|
|
QSE_EXPORT void* qse_dir_getxtn (
|
2012-11-09 17:31:33 +00:00
|
|
|
qse_dir_t* dir
|
|
|
|
);
|
|
|
|
|
2012-12-25 14:10:02 +00:00
|
|
|
QSE_EXPORT qse_dir_errnum_t qse_dir_geterrnum (
|
|
|
|
qse_dir_t* dir
|
|
|
|
);
|
|
|
|
|
2012-11-29 14:03:59 +00:00
|
|
|
QSE_EXPORT int qse_dir_reset (
|
2012-11-09 17:31:33 +00:00
|
|
|
qse_dir_t* dir,
|
|
|
|
const qse_char_t* path
|
|
|
|
);
|
|
|
|
|
2014-11-24 17:01:04 +00:00
|
|
|
/**
|
|
|
|
* The qse_dir_read() function reads a directory entry and
|
|
|
|
* stores it in memory pointed to by \a ent.
|
|
|
|
* \return -1 on failure, 0 upon no more entry, 1 on success
|
|
|
|
*/
|
2012-11-29 14:03:59 +00:00
|
|
|
QSE_EXPORT int qse_dir_read (
|
2012-11-09 17:31:33 +00:00
|
|
|
qse_dir_t* dir,
|
|
|
|
qse_dir_ent_t* ent
|
|
|
|
);
|
|
|
|
|
2014-11-14 02:44:20 +00:00
|
|
|
#if defined(__cplusplus)
|
2012-11-09 17:31:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|