2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Pathname utilities.
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "PathName.h"
|
|
|
|
#include "Util.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <io.h>
|
|
|
|
#include <direct.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/utime.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#ifndef S_ISREG
|
|
|
|
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
|
|
|
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
# ifndef F_OK
|
|
|
|
# define F_OK 00
|
|
|
|
# endif
|
|
|
|
# ifndef R_OK
|
|
|
|
# define R_OK 04
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* Filename utils
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
#define kFilenameExtDelim '.' /* separates extension from filename */
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
const WCHAR* PathName::FilenameOnly(const WCHAR* pathname, WCHAR fssep)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* retstr;
|
|
|
|
const WCHAR* pSlash;
|
2014-11-18 05:13:13 +00:00
|
|
|
WCHAR* tmpStr = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pathname != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (fssep == '\0') {
|
|
|
|
retstr = pathname;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pSlash = wcsrchr(pathname, fssep); // strrchr
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pSlash == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
retstr = pathname; /* whole thing is the filename */
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSlash++;
|
|
|
|
if (*pSlash == '\0') {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (wcslen(pathname) < 2) {
|
2014-11-04 00:26:53 +00:00
|
|
|
retstr = pathname; /* the pathname is just "/"? Whatever */
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* some bonehead put an fssep on the very end; back up before it */
|
|
|
|
/* (not efficient, but this should be rare, and I'm feeling lazy) */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
tmpStr = wcsdup(pathname);
|
|
|
|
tmpStr[wcslen(pathname)-1] = '\0';
|
|
|
|
pSlash = wcsrchr(tmpStr, fssep);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pSlash == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
retstr = pathname; /* just a filename with a '/' after it */
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSlash++;
|
|
|
|
if (*pSlash == '\0') {
|
|
|
|
retstr = pathname; /* I give up! */
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
retstr = pathname + (pSlash - tmpStr);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
retstr = pSlash;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
free(tmpStr);
|
|
|
|
return retstr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
const WCHAR* PathName::FindExtension(const WCHAR* pathname, WCHAR fssep)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* pFilename;
|
|
|
|
const WCHAR* pExt;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to isolate the filename so that we don't get excited
|
|
|
|
* about "/foo.bar/file".
|
|
|
|
*/
|
|
|
|
pFilename = FilenameOnly(pathname, fssep);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pFilename != NULL);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pExt = wcsrchr(pFilename, kFilenameExtDelim);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* also check for "/blah/foo.", which doesn't count */
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pExt != NULL && *(pExt+1) != '\0')
|
2014-11-04 00:26:53 +00:00
|
|
|
return pExt;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
return NULL;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
CString PathName::GetFileName(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString str;
|
|
|
|
|
|
|
|
SplitIFN();
|
|
|
|
str = fFileName;
|
|
|
|
str += fExt;
|
|
|
|
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* ccp;
|
2014-11-04 00:26:53 +00:00
|
|
|
ccp = FilenameOnly(fPathName, '\\');
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (wcscmp(ccp, str) != 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NOTE: got different filenames '%ls' vs '%ls'",
|
2014-11-04 00:26:53 +00:00
|
|
|
ccp, (LPCTSTR) str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
CString PathName::GetDriveOnly(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
SplitIFN();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return fDrive;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
CString PathName::GetDriveAndPath(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString str;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
SplitIFN();
|
|
|
|
str = fDrive;
|
|
|
|
str += fDir;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return str;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
CString PathName::GetPathOnly(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
SplitIFN();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return fDir;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
CString PathName::GetExtension(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
SplitIFN();
|
|
|
|
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* ccp;
|
2014-11-04 00:26:53 +00:00
|
|
|
ccp = FindExtension(fPathName, '\\');
|
2014-11-18 05:13:13 +00:00
|
|
|
if ((ccp == NULL && wcslen(fExt) > 0) ||
|
|
|
|
(ccp != NULL && wcscmp(ccp, fExt) != 0))
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NOTE: got different extensions '%ls' vs '%ls'",
|
2014-11-04 00:26:53 +00:00
|
|
|
ccp, (LPCTSTR) fExt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return fExt;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::SFNToLFN(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR buf[MAX_PATH];
|
2014-11-04 00:26:53 +00:00
|
|
|
WIN32_FIND_DATA findFileData;
|
|
|
|
HANDLE hFind;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR* cp;
|
2014-11-04 00:26:53 +00:00
|
|
|
DWORD len;
|
|
|
|
CString lfn;
|
|
|
|
bool hadEndingSlash = false;
|
|
|
|
|
|
|
|
lfn = "";
|
|
|
|
if (fPathName.IsEmpty())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* fully expand it */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
len = GetFullPathName(fPathName, NELEM(buf), buf, &cp);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (len == 0 || len >= sizeof(buf))
|
|
|
|
return -1;
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" FullPathName='%ls'", buf);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (buf[len-1] == '\\') {
|
|
|
|
hadEndingSlash = true;
|
|
|
|
buf[len-1] = '\0';
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Walk forward in the buffer, passing increasingly-long filenames into
|
|
|
|
* FindFirstFile.
|
|
|
|
*/
|
|
|
|
cp = buf;
|
|
|
|
while (cp != buf + len) {
|
|
|
|
if (*cp == '\\') {
|
|
|
|
if (cp == buf) {
|
|
|
|
/* just the leading '\'; shouldn't happen after GetFPN? */
|
|
|
|
lfn += "\\";
|
|
|
|
} else if (cp == buf+2 && *buf != '\\') {
|
|
|
|
/* this is probably "C:\", which FindFF doesn't handle */
|
|
|
|
*cp = '\0';
|
|
|
|
lfn += buf;
|
|
|
|
lfn += "\\";
|
|
|
|
*cp = '\\';
|
|
|
|
} else {
|
|
|
|
*cp = '\0';
|
|
|
|
hFind = ::FindFirstFile(buf, &findFileData);
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE) {
|
|
|
|
DWORD err = ::GetLastError();
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("FindFirstFile '%ls' failed, err=%d", buf, err);
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
FindClose(hFind);
|
|
|
|
}
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" COMPONENT '%ls' [%ls]", findFileData.cFileName,
|
2014-11-04 00:26:53 +00:00
|
|
|
// findFileData.cAlternateFileName);
|
|
|
|
lfn += findFileData.cFileName;
|
|
|
|
lfn += "\\";
|
|
|
|
*cp = '\\';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cp++;
|
|
|
|
}
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" Interim name = '%ls'", (LPCTSTR) lfn);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (*(cp-1) != '\\') {
|
|
|
|
/* there was some stuff after the last '\\'; handle it */
|
|
|
|
hFind = ::FindFirstFile(buf, &findFileData);
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE) {
|
|
|
|
DWORD err = ::GetLastError();
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("FindFirstFile '%ls' failed, err=%d", buf, err);
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
FindClose(hFind);
|
|
|
|
}
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" COMPONENT2 '%ls' [%ls]", findFileData.cFileName,
|
2014-11-04 00:26:53 +00:00
|
|
|
// findFileData.cAlternateFileName);
|
|
|
|
lfn += findFileData.cFileName;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" Almost done = '%ls'", (LPCTSTR) lfn);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (hadEndingSlash)
|
|
|
|
lfn += "\\";
|
|
|
|
|
|
|
|
fPathName = lfn;
|
|
|
|
|
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
CString PathName::GetDescription()
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString szTypeName;
|
2014-11-19 22:54:24 +00:00
|
|
|
SHFILEINFO sfi = { 0 };
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
SHGetFileInfo(fPathName, 0, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
szTypeName = sfi.szTypeName;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return szTypeName;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
bool PathName::Exists(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-25 22:34:14 +00:00
|
|
|
/*
|
|
|
|
* If we use something simple like access(), we will catch all files including
|
|
|
|
* the ones in Network Neighborhood. Using the FindFirstFile stuff avoids
|
|
|
|
* the problem, but raises the difficulty of being unable to find simple
|
|
|
|
* things like "D:\".
|
|
|
|
*/
|
2007-03-27 17:47:10 +00:00
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return (::_waccess(fPathName, 0) != -1);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
#if 0
|
2014-11-04 00:26:53 +00:00
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
bool result;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
CString szFindPath = fPathName;
|
|
|
|
int nSlash = szFindPath.ReverseFind('\\');
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if( nSlash == szFindPath.GetLength()-1)
|
|
|
|
{
|
|
|
|
szFindPath = szFindPath.Left(nSlash);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
HANDLE hFind = FindFirstFile( szFindPath, &fd );
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if ( hFind != INVALID_HANDLE_VALUE )
|
|
|
|
{
|
|
|
|
FindClose( hFind );
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
result = (hFind != INVALID_HANDLE_VALUE);
|
2007-03-27 17:47:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
2014-11-04 00:26:53 +00:00
|
|
|
if (::access(fPathName, 0) != -1) {
|
|
|
|
/* exists */
|
|
|
|
if (!result) {
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* doesn't exist */
|
|
|
|
if (result) {
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Problem:
|
|
|
|
FindFirstFile returns INVALID_HANDLE_VALUE while seeking "C:"
|
|
|
|
|
|
|
|
my workaround:
|
|
|
|
instead of removing the backshash at the end of the path, i add a * to find any file in this folder.
|
|
|
|
|
|
|
|
FileName.cpp line 135:
|
|
|
|
replace
|
|
|
|
----------------------
|
2014-11-04 00:26:53 +00:00
|
|
|
if( nSlash == szFindPath.GetLength()-1)
|
|
|
|
{
|
|
|
|
szFindPath = szFindPath.Left(nSlash);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
----------------------
|
|
|
|
with
|
|
|
|
----------------------
|
2014-11-04 00:26:53 +00:00
|
|
|
if( nSlash == szFindPath.GetLength()-1)
|
|
|
|
{
|
|
|
|
szFindPath += "*";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
szFindPath += "\\*";
|
2007-03-27 17:47:10 +00:00
|
|
|
----------------------
|
|
|
|
*/
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::Mkdir(const WCHAR* dir)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
int err = 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(dir != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (_wmkdir(dir) < 0)
|
2014-11-04 00:26:53 +00:00
|
|
|
err = errno ? errno : -1;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return err;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb,
|
2014-11-04 00:26:53 +00:00
|
|
|
time_t* pModWhen, bool* pExists, bool* pIsReadable, bool* pIsDirectory)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
struct _stat sbuf;
|
2014-11-04 00:26:53 +00:00
|
|
|
int cc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On base network path, e.g. \\webby\fadden, the stat() call fails
|
|
|
|
* with ENOENT, but the access() call succeeds. Not sure if this
|
|
|
|
* can happen in other circumstances, so I'm not messing with it
|
|
|
|
* for now.
|
|
|
|
*/
|
|
|
|
//{
|
|
|
|
// int cc2 = access(pathname, 0);
|
|
|
|
//}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pModWhen != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pModWhen = (time_t) -1;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pExists != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pExists = false;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pIsReadable != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pIsReadable = false;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pIsDirectory != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pIsDirectory = false;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
cc = _wstat(pathname, &sbuf);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (psb != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*psb = sbuf;
|
|
|
|
if (cc != 0) {
|
|
|
|
if (errno == ENOENT) {
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pExists != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pExists = false;
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return errno;
|
|
|
|
}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pExists != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pExists = true;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pIsDirectory != NULL && S_ISDIR(sbuf.st_mode))
|
2014-11-04 00:26:53 +00:00
|
|
|
*pIsDirectory = true;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pModWhen != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pModWhen = sbuf.st_mtime;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pIsReadable != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/*
|
|
|
|
* Test if we can read this file. How do we do that? The easy but
|
|
|
|
* slow way is to call access(2), the harder way is to figure out
|
|
|
|
* what user/group we are and compare the appropriate file mode.
|
|
|
|
*/
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (_waccess(pathname, R_OK) < 0)
|
2014-11-04 00:26:53 +00:00
|
|
|
*pIsReadable = false;
|
|
|
|
else
|
|
|
|
*pIsReadable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::CheckFileStatus(struct _stat* psb, bool* pExists, bool* pIsReadable,
|
2014-11-04 00:26:53 +00:00
|
|
|
bool* pIsDir)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
return GetFileInfo(fPathName, psb, NULL, pExists, pIsReadable, pIsDir);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
time_t PathName::GetModWhen(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
time_t when;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (GetFileInfo(fPathName, NULL, &when, NULL, NULL, NULL) != 0)
|
2014-11-04 00:26:53 +00:00
|
|
|
return (time_t) -1;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return when;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::SetModWhen(time_t when)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
struct _utimbuf utbuf;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (when == (time_t) -1 || when == kDateNone || when == kDateInvalid) {
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGI("NOTE: not setting invalid date (%I64d)", (long long) when);
|
2014-11-04 00:26:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
utbuf.actime = utbuf.modtime = when;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (_wutime(fPathName, &utbuf) < 0)
|
2014-11-04 00:26:53 +00:00
|
|
|
return errno;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd,
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR fssep)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
int err = 0;
|
2014-11-18 05:13:13 +00:00
|
|
|
WCHAR* tmpBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
bool isDirectory;
|
|
|
|
bool exists;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pathStart != NULL);
|
|
|
|
ASSERT(pathEnd != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(fssep != '\0');
|
|
|
|
|
|
|
|
/* pathStart might have whole path, but we only want up to "pathEnd" */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
tmpBuf = wcsdup(pathStart);
|
2014-11-04 00:26:53 +00:00
|
|
|
tmpBuf[pathEnd - pathStart +1] = '\0';
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
err = GetFileInfo(tmpBuf, NULL, NULL, &exists, NULL, &isDirectory);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (err != 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Could not get file info for '%ls'", tmpBuf);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
} else if (!exists) {
|
|
|
|
/* dir doesn't exist; move up a level and check parent */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pathEnd = wcsrchr(tmpBuf, fssep);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pathEnd != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pathEnd--;
|
|
|
|
ASSERT(pathEnd >= tmpBuf);
|
|
|
|
err = CreateSubdirIFN(tmpBuf, pathEnd, fssep);
|
|
|
|
if (err != 0)
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parent is taken care of; create this one */
|
|
|
|
err = Mkdir(tmpBuf);
|
|
|
|
if (err != 0)
|
|
|
|
goto bail;
|
|
|
|
} else {
|
|
|
|
/* file does exist, make sure it's a directory */
|
|
|
|
if (!isDirectory) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Existing file '%ls' is not a directory", tmpBuf);
|
2014-11-04 00:26:53 +00:00
|
|
|
err = ENOTDIR;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
free(tmpBuf);
|
|
|
|
return err;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int PathName::CreatePathIFN(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
int err = 0;
|
|
|
|
CString pathName(fPathName);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR* pathStart;
|
|
|
|
const WCHAR* pathEnd;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
ASSERT(fFssep != '\0');
|
|
|
|
|
2014-11-19 22:54:24 +00:00
|
|
|
pathStart = pathName.GetBuffer(1);
|
2014-11-04 00:26:53 +00:00
|
|
|
/* BAD: network paths begin with "\\", not a drive letter */
|
|
|
|
// if (pathStart[0] == fFssep)
|
|
|
|
// pathStart++;
|
|
|
|
|
|
|
|
/* remove trailing fssep */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (pathStart[wcslen(pathStart)-1] == fFssep)
|
|
|
|
pathStart[wcslen(pathStart)-1] = '\0';
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* work around bug in Win32 strrchr */
|
|
|
|
if (pathStart[0] == '\0' || pathStart[1] == '\0') {
|
|
|
|
err = EINVAL;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pathEnd = wcsrchr(pathStart, fFssep);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pathEnd == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/* no subdirectory components found */
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
pathEnd--; // back up past the fssep
|
|
|
|
|
|
|
|
ASSERT(pathEnd >= pathStart);
|
|
|
|
if (pathEnd - pathStart < 0) {
|
|
|
|
err = EINVAL;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Special-case the root directory, e.g. "C:\", which needs the final
|
|
|
|
* slash to be recognized by Windows file calls.
|
|
|
|
*/
|
|
|
|
if (pathEnd - pathStart == 1 && pathStart[1] == ':' &&
|
|
|
|
(toupper(pathStart[0]) >= 'A' && toupper(pathStart[0]) <= 'Z'))
|
|
|
|
{
|
|
|
|
pathEnd++; // put it back on
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test to determine which directories exist. The most likely case
|
|
|
|
* is that some or all of the components have already been created,
|
|
|
|
* so we start with the last one and work backward.
|
|
|
|
*/
|
|
|
|
err = CreateSubdirIFN(pathStart, pathEnd, fFssep);
|
|
|
|
/* fall through with err */
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
pathName.ReleaseBuffer();
|
|
|
|
return err;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|