From 672f058697d6ca0a126d5f1cac3aa8d4051f3b68 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 4 Nov 2002 21:20:56 +0000 Subject: [PATCH] trailing slash implies directory name --- dtool/src/dtoolutil/filename.cxx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index eb057abe01..c1a3458d76 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -1403,12 +1403,27 @@ rename_to(const Filename &other) const { // itself. This assumes that the Filename contains the // name of a file, not a directory name; it ensures that // the directory containing the file exists. +// +// However, if the filename ends in a slash, it assumes +// the Filename represents the name of a directory, and +// creates all the paths. //////////////////////////////////////////////////////////////////// bool Filename:: make_dir() const { + if (empty()) { + return false; + } Filename path = *this; path.standardize(); - string dirname = path.get_dirname(); + string dirname; + if (_filename[_filename.length() - 1] == '/') { + // The Filename ends in a slash; it represents a directory. + dirname = path.get_fullpath(); + + } else { + // The Filename does not end in a slash; it represents a file. + dirname = path.get_dirname(); + } // First, make sure everything up to the last path is known. We // don't care too much if any of these fail; maybe they failed