qse/qse/lib/cmn/fs-err.c

151 lines
2.7 KiB
C
Raw Normal View History

/*
* $Id$
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fs.h"
qse_fs_errnum_t qse_fs_geterrnum (qse_fs_t* fs)
{
return fs->errnum;
}
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:
case ERROR_INVALID_NAME:
case ERROR_DIRECTORY:
return QSE_FS_EINVAL;
case ERROR_ACCESS_DENIED:
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;
default:
2012-02-21 09:23:51 +00:00
return QSE_FS_ESYSERR;
}
2012-02-21 09:23:51 +00:00
#elif defined(__OS2__)
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:
return QSE_FS_EINVAL;
2012-02-21 09:23:51 +00:00
case ERROR_ACCESS_DENIED:
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;
2012-02-21 09:23:51 +00:00
case EACCES:
2011-12-02 16:05:16 +00:00
case EPERM:
2012-02-21 09:23:51 +00:00
return QSE_FS_EACCES;
2011-12-02 16:05:16 +00:00
case ENOENT:
case ENOTDIR:
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;
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:
case EPERM:
return QSE_FS_EACCES;
case ENOENT:
case ENOTDIR:
return QSE_FS_ENOENT;
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;
2011-12-02 16:05:16 +00:00
case EXDEV:
return QSE_FS_EXDEV;
default:
2012-02-21 09:23:51 +00:00
return QSE_FS_ESYSERR;
}
#endif
}