00001 // LICENSE: (Please see the file COPYING for details) 00002 // 00003 // NUS - Nemesis Utilities System: A C++ application development framework 00004 // Copyright (C) 2006, 2007 Otavio Rodolfo Piske 00005 // 00006 // This file is part of NUS 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Lesser General Public 00010 // License as published by the Free Software Foundation version 2.1 00011 // of the License. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Lesser General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Lesser General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 // 00022 #include "nioexception.h" 00023 00024 00025 DllDeclSpec const Flag NIOException::IO_NOT_FOUND = 1; 00026 DllDeclSpec const Flag NIOException::IO_ACCESS_DENIED = 2; 00027 DllDeclSpec const Flag NIOException::IO_SYSTEM = 3; 00028 DllDeclSpec const Flag NIOException::IO_NO_SPACE = 4; 00029 DllDeclSpec const Flag NIOException::IO_IO_ERROR = 5; 00030 00031 00032 NIOException::NIOException(const NString &desc, const NString &name, Module module, 00033 Resource resource, Flag flag) 00034 : NException(desc, module, flag), 00035 m_resource(UNKNOWN), 00036 m_name(name) 00037 { 00038 00039 } 00040 00041 00042 NIOException::Resource NIOException::getResource(void) const { 00043 return m_resource; 00044 } 00045 00046 00047 NString NIOException::getResourceName(void) const { 00048 return m_name; 00049 } 00050 00051 Flag NIOException::getFlagByErr(nuint32 errno_val) { 00052 Flag ret = 0; 00053 00054 switch (errno_val) { 00055 case EPERM: 00056 case EACCES: { 00057 ret = IO_ACCESS_DENIED; 00058 break; 00059 } 00060 case ENOSPC: { 00061 ret = IO_NO_SPACE; 00062 break; 00063 } 00064 case EIO: { 00065 ret = IO_IO_ERROR; 00066 break; 00067 } 00068 case ENXIO: { 00069 ret = IO_NOT_FOUND; 00070 break; 00071 } 00072 default: { 00073 ret = IO_SYSTEM; 00074 break; 00075 } 00076 } 00077 00078 return ret; 00079 }