• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

GnashFileUtilities.h

Go to the documentation of this file.
00001 // GnashFileUtilities.h     File handling for Gnash
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00004 //   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     //
00051     inline int mkdirUserPermissions(const std::string& dirname)
00052     {
00053 #if !defined(_WIN32) && !defined(_MSC_VER) && !defined(__amigaos4__)
00054         return mkdir(dirname.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);
00055 #elif defined(__amigaos4__)
00056       // on AmigaOS4 if you try to create a directory that is an assign or a drive
00057       // you will receive an EINVAL or an ENOTDIR instead of EEXIST and so will force it
00058       int ret = 0;
00059       ret =  mkdir(dirname.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);
00060       if (errno == EINVAL || errno == ENOTDIR)
00061           errno = EEXIST;
00062       return ret;
00063 #else
00064         return mkdir(dirname.c_str());
00065 #endif
00066     }
00067 
00069     //
00071     DSOEXPORT bool mkdirRecursive(const std::string& filename);
00072 
00073 } // namespace gnash
00074 
00075 #endif

Generated on Fri Mar 16 2012 15:46:10 for Gnash by  doxygen 1.7.1