Gnash
0.8.10
|
00001 // GnashFileUtilities.h File handling for Gnash 00002 // 00003 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 00004 // Free Software Foundation, Inc 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 // 00020 00022 // 00028 #ifndef GNASH_FILE_UTILITIES_H 00029 #define GNASH_FILE_UTILITIES_H 00030 00031 #include "dsodefs.h" 00032 00033 #if !defined(_MSC_VER) 00034 # include <unistd.h> 00035 # include <sys/stat.h> 00036 # include <sys/types.h> 00037 # include <dirent.h> 00038 # include <cerrno> 00039 #else 00040 #include <io.h> 00041 #define dup _dup 00042 #endif 00043 00044 #include <string> 00045 00046 namespace gnash { 00047 00049 // 00055 inline int mkdirUserPermissions(const std::string& dirname) 00056 { 00057 #if !defined(_WIN32) && !defined(_MSC_VER) && !defined(__amigaos4__) 00058 return mkdir(dirname.c_str(), S_IRUSR | S_IWUSR | S_IXUSR); 00059 #elif defined(__amigaos4__) 00060 // on AmigaOS4 if you try to create a directory that is an assign or a drive 00061 // you will receive an EINVAL or an ENOTDIR instead of EEXIST and so will force it 00062 int ret = 0; 00063 ret = mkdir(dirname.c_str(), S_IRUSR | S_IWUSR | S_IXUSR); 00064 if (errno == EINVAL || errno == ENOTDIR) 00065 errno = EEXIST; 00066 return ret; 00067 #else 00068 return mkdir(dirname.c_str()); 00069 #endif 00070 } 00071 00073 // 00079 DSOEXPORT bool mkdirRecursive(const std::string& filename); 00080 00081 } // namespace gnash 00082 00083 #endif