*** empty log message ***

This commit is contained in:
Mike Goslin 2000-10-04 23:09:03 +00:00
parent 117fa0038c
commit 8ff24f8f4f
3 changed files with 29 additions and 0 deletions

View File

@ -810,6 +810,31 @@ rename_to(const Filename &other) const {
other.to_os_specific().c_str()) == 0);
}
////////////////////////////////////////////////////////////////////
// Function: Filename::mkdir
// Access: Public
// Description: Creates all the directories in the path to the file
// specified in the filename (useful for writing).
////////////////////////////////////////////////////////////////////
bool Filename::
make_dir() const {
size_t p = 0;
while (p < _filename.length()) {
size_t slash = _filename.find('/', p);
if (slash != string::npos) {
string component = _filename.substr(0, slash);
if (!(component == ".") ||
!(component == "..")) {
mkdir(component.c_str(), 0xffff);
}
}
p = slash;
while (p < _filename.length() && _filename[p] == '/')
p++;
}
return true;
}
////////////////////////////////////////////////////////////////////
// Function: Filename::locate_basename

View File

@ -134,6 +134,8 @@ public:
bool unlink() const;
bool rename_to(const Filename &other) const;
bool make_dir() const;
// Comparison operators are handy.
INLINE bool operator == (const string &other) const;
INLINE bool operator != (const string &other) const;

View File

@ -236,6 +236,7 @@ bool Multifile::Memfile::
write(void) {
ofstream write_stream;
_name.set_binary();
_name.make_dir();
if (!_name.open_write(write_stream)) {
express_cat.error()
<< "Multifile::Memfile::write() - Failed to open output file: "
@ -287,6 +288,7 @@ write(char *&start, int &size) {
// Try to open the file for writing
if (_file_open == false) {
_name.set_binary();
_name.make_dir();
if ((_file_open = _name.open_write(_write_stream)) == false) {
express_cat.error()
<< "Multfile::Memfile::write() - Couldn't open file: "