1 // GnashFileUtilities.h File handling for Gnash
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4 // 2011 Free Software Foundation, Inc
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.
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.
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
21 /// This file should also be included for the following system functions:
28 #ifndef GNASH_FILE_UTILITIES_H
29 #define GNASH_FILE_UTILITIES_H
33 #if !defined(_MSC_VER)
35 # include <sys/stat.h>
36 # include <sys/types.h>
48 /// Create a directory, granting owner rwx permissions.
50 /// On non-POSIX systems, just create the directory.
53 /// Directory name, may be absolute or relative to CWD
55 inline int mkdirUserPermissions(const std::string
& dirname
)
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
63 ret
= mkdir(dirname
.c_str(), S_IRUSR
| S_IWUSR
| S_IXUSR
);
64 if (errno
== EINVAL
|| errno
== ENOTDIR
)
68 return mkdir(dirname
.c_str());
72 /// Create a directory for a given filename.
74 /// Everything after the last '/' is assumed to be the filename.
77 /// Full file path, may be absolute or relative to CWD
79 DSOEXPORT
bool mkdirRecursive(const std::string
& filename
);