mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
mkdir, rmdir
This commit is contained in:
parent
88552b956c
commit
1a02e76c28
@ -2576,9 +2576,9 @@ make_dir() const {
|
||||
Filename component(dirname.substr(0, slash));
|
||||
string os_specific = component.to_os_specific();
|
||||
#ifndef WIN32_VC
|
||||
mkdir(os_specific.c_str(), 0777);
|
||||
::mkdir(os_specific.c_str(), 0777);
|
||||
#else
|
||||
mkdir(os_specific.c_str());
|
||||
::mkdir(os_specific.c_str());
|
||||
#endif
|
||||
slash = dirname.find('/', slash + 1);
|
||||
}
|
||||
@ -2587,9 +2587,54 @@ make_dir() const {
|
||||
Filename component(dirname);
|
||||
string os_specific = component.to_os_specific();
|
||||
#ifndef WIN32_VC
|
||||
int result = mkdir(os_specific.c_str(), 0777);
|
||||
int result = ::mkdir(os_specific.c_str(), 0777);
|
||||
#else
|
||||
int result = mkdir(os_specific.c_str());
|
||||
int result = ::mkdir(os_specific.c_str());
|
||||
#endif
|
||||
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Filename::mkdir
|
||||
// Access: Published
|
||||
// Description: Creates the directory named by this filename. Unlike
|
||||
// make_dir(), this assumes that the Filename contains
|
||||
// the directory name itself. Also, parent directories
|
||||
// are not automatically created; this function fails if
|
||||
// any parent directory is missing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
mkdir() const {
|
||||
string os_specific = to_os_specific();
|
||||
#ifndef WIN32_VC
|
||||
int result = ::mkdir(os_specific.c_str(), 0777);
|
||||
#else
|
||||
int result = ::mkdir(os_specific.c_str());
|
||||
#endif
|
||||
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Filename::rmdir
|
||||
// Access: Published
|
||||
// Description: The inverse of mkdir(): this removes the directory
|
||||
// named by this Filename, if it is in fact a directory.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Filename::
|
||||
rmdir() const {
|
||||
string os_specific = to_os_specific();
|
||||
|
||||
int result = ::rmdir(os_specific.c_str());
|
||||
|
||||
#ifdef WIN32
|
||||
if (result != 0) {
|
||||
// Windows may require the directory to be writable before we can
|
||||
// remove it.
|
||||
chmod(os_specific.c_str(), 0777);
|
||||
result = ::rmdir(os_specific.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
return (result == 0);
|
||||
|
@ -203,6 +203,8 @@ PUBLISHED:
|
||||
bool copy_to(const Filename &other) const;
|
||||
|
||||
bool make_dir() const;
|
||||
bool mkdir() const;
|
||||
bool rmdir() const;
|
||||
|
||||
// Comparison operators are handy.
|
||||
INLINE bool operator == (const string &other) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user