2011-11-20 16:24:11 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2019-06-06 05:28:23 +00:00
|
|
|
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
2011-11-20 16:24:11 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
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.
|
2011-11-20 16:24:11 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
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.
|
2011-11-20 16:24:11 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-29 03:55:42 +00:00
|
|
|
#include "fs-prv.h"
|
2011-11-20 16:24:11 +00:00
|
|
|
|
|
|
|
qse_fs_errnum_t qse_fs_syserrtoerrnum (qse_fs_t* fs, qse_fs_syserr_t e)
|
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
|
|
|
switch (e)
|
|
|
|
{
|
2012-02-21 09:23:51 +00:00
|
|
|
case ERROR_NOT_ENOUGH_MEMORY:
|
|
|
|
case ERROR_OUTOFMEMORY:
|
|
|
|
return QSE_FS_ENOMEM;
|
|
|
|
|
|
|
|
case ERROR_INVALID_PARAMETER:
|
|
|
|
case ERROR_INVALID_HANDLE:
|
2011-11-20 16:24:11 +00:00
|
|
|
case ERROR_INVALID_NAME:
|
|
|
|
case ERROR_DIRECTORY:
|
|
|
|
return QSE_FS_EINVAL;
|
|
|
|
|
|
|
|
case ERROR_ACCESS_DENIED:
|
2012-12-10 14:39:57 +00:00
|
|
|
case ERROR_SHARING_VIOLATION:
|
2011-11-20 16:24:11 +00:00
|
|
|
return QSE_FS_EACCES;
|
|
|
|
|
|
|
|
case ERROR_FILE_NOT_FOUND:
|
|
|
|
case ERROR_PATH_NOT_FOUND:
|
|
|
|
return QSE_FS_ENOENT;
|
|
|
|
|
|
|
|
case ERROR_ALREADY_EXISTS:
|
|
|
|
case ERROR_FILE_EXISTS:
|
|
|
|
return QSE_FS_EEXIST;
|
2012-02-21 09:23:51 +00:00
|
|
|
|
|
|
|
case ERROR_NOT_SAME_DEVICE:
|
|
|
|
return QSE_FS_EXDEV;
|
2014-11-24 17:01:04 +00:00
|
|
|
|
2014-11-28 17:01:29 +00:00
|
|
|
case ERROR_DIR_NOT_EMPTY:
|
|
|
|
return QSE_FS_ENOTVOID;
|
2014-11-24 17:01:04 +00:00
|
|
|
|
2011-11-20 16:24:11 +00:00
|
|
|
default:
|
2012-02-21 09:23:51 +00:00
|
|
|
return QSE_FS_ESYSERR;
|
2011-11-20 16:24:11 +00:00
|
|
|
}
|
2012-02-21 09:23:51 +00:00
|
|
|
#elif defined(__OS2__)
|
|
|
|
|
2011-11-20 16:24:11 +00:00
|
|
|
switch (e)
|
|
|
|
{
|
2012-02-21 09:23:51 +00:00
|
|
|
case ERROR_NOT_ENOUGH_MEMORY:
|
|
|
|
return QSE_FS_ENOMEM;
|
|
|
|
|
|
|
|
case ERROR_INVALID_PARAMETER:
|
|
|
|
case ERROR_INVALID_HANDLE:
|
|
|
|
case ERROR_INVALID_NAME:
|
2011-11-20 16:24:11 +00:00
|
|
|
return QSE_FS_EINVAL;
|
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
case ERROR_ACCESS_DENIED:
|
2012-12-10 14:39:57 +00:00
|
|
|
case ERROR_SHARING_VIOLATION:
|
2012-02-21 09:23:51 +00:00
|
|
|
return QSE_FS_EACCES;
|
|
|
|
|
|
|
|
case ERROR_FILE_NOT_FOUND:
|
|
|
|
case ERROR_PATH_NOT_FOUND:
|
|
|
|
return QSE_FS_ENOENT;
|
|
|
|
|
|
|
|
case ERROR_ALREADY_EXISTS:
|
|
|
|
return QSE_FS_EEXIST;
|
|
|
|
|
|
|
|
case ERROR_NOT_SAME_DEVICE:
|
|
|
|
return QSE_FS_EXDEV;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return QSE_FS_ESYSERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(__DOS__)
|
|
|
|
|
|
|
|
switch (e)
|
|
|
|
{
|
2011-12-02 16:05:16 +00:00
|
|
|
case ENOMEM:
|
|
|
|
return QSE_FS_ENOMEM;
|
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
case EINVAL:
|
|
|
|
return QSE_FS_EINVAL;
|
2011-11-20 16:24:11 +00:00
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
case EACCES:
|
|
|
|
return QSE_FS_EACCES;
|
2011-12-02 16:05:16 +00:00
|
|
|
|
2016-12-17 17:38:03 +00:00
|
|
|
case EPERM:
|
|
|
|
return QSE_FS_EPERM;
|
|
|
|
|
2011-11-20 16:24:11 +00:00
|
|
|
case ENOENT:
|
|
|
|
return QSE_FS_ENOENT;
|
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
case EEXIST:
|
|
|
|
return QSE_FS_EEXIST;
|
|
|
|
|
2011-12-02 16:05:16 +00:00
|
|
|
case EISDIR:
|
|
|
|
return QSE_FS_EISDIR;
|
2011-11-20 16:24:11 +00:00
|
|
|
|
2014-11-24 17:01:04 +00:00
|
|
|
case ENOTDIR:
|
|
|
|
return QSE_FS_ENOTDIR;
|
|
|
|
|
2014-12-03 15:27:45 +00:00
|
|
|
case EXDEV:
|
|
|
|
return QSE_FS_EXDEV;
|
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
default:
|
|
|
|
return QSE_FS_ESYSERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
switch (e)
|
|
|
|
{
|
|
|
|
case ENOMEM:
|
|
|
|
return QSE_FS_ENOMEM;
|
|
|
|
|
|
|
|
case EINVAL:
|
|
|
|
return QSE_FS_EINVAL;
|
|
|
|
|
|
|
|
case EACCES:
|
|
|
|
return QSE_FS_EACCES;
|
|
|
|
|
2016-12-17 17:38:03 +00:00
|
|
|
case EPERM:
|
|
|
|
return QSE_FS_EPERM;
|
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
case ENOENT:
|
|
|
|
return QSE_FS_ENOENT;
|
|
|
|
|
2011-11-20 16:24:11 +00:00
|
|
|
case EEXIST:
|
|
|
|
return QSE_FS_EEXIST;
|
|
|
|
|
2012-02-21 09:23:51 +00:00
|
|
|
case EINTR:
|
|
|
|
return QSE_FS_EINTR;
|
|
|
|
|
|
|
|
case EISDIR:
|
|
|
|
return QSE_FS_EISDIR;
|
|
|
|
|
2014-11-24 17:01:04 +00:00
|
|
|
case ENOTDIR:
|
|
|
|
return QSE_FS_ENOTDIR;
|
|
|
|
|
|
|
|
case ENOTEMPTY:
|
|
|
|
return QSE_FS_ENOTVOID;
|
|
|
|
|
2011-12-02 16:05:16 +00:00
|
|
|
case EXDEV:
|
|
|
|
return QSE_FS_EXDEV;
|
|
|
|
|
2011-11-20 16:24:11 +00:00
|
|
|
default:
|
2012-02-21 09:23:51 +00:00
|
|
|
return QSE_FS_ESYSERR;
|
2011-11-20 16:24:11 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2014-11-25 03:25:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
qse_fs_errnum_t qse_fs_direrrtoerrnum (qse_fs_t* fs, qse_dir_errnum_t e)
|
|
|
|
{
|
|
|
|
switch (e)
|
|
|
|
{
|
|
|
|
case QSE_DIR_ENOERR:
|
|
|
|
return QSE_FS_ENOERR;
|
|
|
|
|
|
|
|
case QSE_DIR_EOTHER:
|
|
|
|
return QSE_FS_EOTHER;
|
|
|
|
|
|
|
|
case QSE_DIR_ENOIMPL:
|
|
|
|
return QSE_FS_ENOIMPL;
|
|
|
|
|
|
|
|
case QSE_DIR_ESYSERR:
|
|
|
|
return QSE_FS_ESYSERR;
|
|
|
|
|
|
|
|
case QSE_DIR_EINTERN:
|
|
|
|
return QSE_FS_EINTERN;
|
|
|
|
|
|
|
|
case QSE_DIR_ENOMEM:
|
|
|
|
return QSE_FS_ENOMEM;
|
|
|
|
|
|
|
|
case QSE_DIR_EINVAL:
|
|
|
|
return QSE_FS_EINVAL;
|
|
|
|
|
|
|
|
case QSE_DIR_EACCES:
|
|
|
|
return QSE_FS_EACCES;
|
|
|
|
|
2016-12-17 17:38:03 +00:00
|
|
|
case QSE_DIR_EPERM:
|
|
|
|
return QSE_FS_EPERM;
|
|
|
|
|
2014-11-25 03:25:46 +00:00
|
|
|
case QSE_DIR_ENOENT:
|
|
|
|
return QSE_FS_ENOENT;
|
|
|
|
|
|
|
|
case QSE_DIR_EEXIST:
|
|
|
|
return QSE_FS_EEXIST;
|
|
|
|
|
|
|
|
case QSE_DIR_EINTR:
|
|
|
|
return QSE_FS_EINTR;
|
|
|
|
|
|
|
|
case QSE_DIR_EPIPE:
|
|
|
|
return QSE_FS_EPIPE;
|
|
|
|
|
|
|
|
case QSE_DIR_EAGAIN:
|
|
|
|
return QSE_FS_EAGAIN;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return QSE_FS_EOTHER;
|
|
|
|
}
|
|
|
|
}
|