Gnash  0.8.11dev
GnashFileUtilities.h
Go to the documentation of this file.
1 // GnashFileUtilities.h File handling for Gnash
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 
22 //
28 #ifndef GNASH_FILE_UTILITIES_H
29 #define GNASH_FILE_UTILITIES_H
30 
31 #include "dsodefs.h"
32 
33 #if !defined(_MSC_VER)
34 # include <unistd.h>
35 # include <sys/stat.h>
36 # include <sys/types.h>
37 # include <dirent.h>
38 # include <cerrno>
39 #else
40 #include <io.h>
41 #define dup _dup
42 #endif
43 
44 #include <string>
45 
46 namespace gnash {
47 
49  //
55  inline int mkdirUserPermissions(const std::string& dirname)
56  {
57 #if !defined(_WIN32) && !defined(_MSC_VER) && !defined(__amigaos4__)
58  return mkdir(dirname.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);
59 #elif defined(__amigaos4__)
60  // on AmigaOS4 if you try to create a directory that is an assign or a drive
61  // you will receive an EINVAL or an ENOTDIR instead of EEXIST and so will force it
62  int ret = 0;
63  ret = mkdir(dirname.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);
64  if (errno == EINVAL || errno == ENOTDIR)
65  errno = EEXIST;
66  return ret;
67 #else
68  return mkdir(dirname.c_str());
69 #endif
70  }
71 
73  //
79  DSOEXPORT bool mkdirRecursive(const std::string& filename);
80 
81 } // namespace gnash
82 
83 #endif
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
bool mkdirRecursive(const std::string &filename)
Create a directory for a given filename.
Definition: GnashFileUtilities.cpp:35
#define DSOEXPORT
Definition: dsodefs.h:55
int mkdirUserPermissions(const std::string &dirname)
Create a directory, granting owner rwx permissions.
Definition: GnashFileUtilities.h:55