You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
(12) |
May
(1) |
Jun
|
Jul
(14) |
Aug
(750) |
Sep
(4) |
Oct
(10) |
Nov
(1) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
|
Feb
|
Mar
(20) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ben...@id...> - 2004-05-22 12:30:23
|
Dear Open Source developer I am doing a research project on "Fun and Software Development" in which I kindly invite you to participate. You will find the online survey under http://fasd.ethz.ch/qsf/. The questionnaire consists of 53 questions and you will need about 15 minutes to complete it. With the FASD project (Fun and Software Development) we want to define the motivational significance of fun when software developers decide to engage in Open Source projects. What is special about our research project is that a similar survey is planned with software developers in commercial firms. This procedure allows the immediate comparison between the involved individuals and the conditions of production of these two development models. Thus we hope to obtain substantial new insights to the phenomenon of Open Source Development. With many thanks for your participation, Benno Luthiger PS: The results of the survey will be published under http://www.isu.unizh.ch/fuehrung/blprojects/FASD/. We have set up the mailing list fa...@we... for this study. Please see http://fasd.ethz.ch/qsf/mailinglist_en.html for registration to this mailing list. _______________________________________________________________________ Benno Luthiger Swiss Federal Institute of Technology Zurich 8092 Zurich Mail: benno.luthiger(at)id.ethz.ch _______________________________________________________________________ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:14
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Win In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Files/Source/Files/Win Modified Files: WFileSystem.cpp WMemoryMappedFile.cpp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: WFileSystem.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Win/WFileSystem.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** WFileSystem.cpp 15 Aug 2003 09:57:52 -0000 1.9 --- WFileSystem.cpp 28 Mar 2004 22:13:16 -0000 1.10 *************** *** 1,913 **** ! /* ! * File: WFileSystem.cpp ! * Summary: Some handy functions for dealing with the file system. ! * Written by: Jesse Jones ! * ! * Copyright © 1998-2001 Jesse Jones. ! * This code is distributed under the zlib/libpng license (see License.txt for details). ! * ! * Change History (most recent first): ! * ! * $Log$ ! * Revision 1.9 2003/08/15 09:57:52 meeroh ! * Macro changes: ! * MAC -> TARGET_OS_MAC ! * WIN -> TARGET_OS_WIN32 ! * TARGET_CARBON -> TARGET_API_MAC_CARBON ! * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN ! * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN ! * CODE_WARRIOR -> TARGET_CC_METROWERKS ! * __MWERKS__ -> TARGET_CC_METROWERKS ! * MSVC -> TARGET_CC_MICROSOFT ! * _MSC_VER -> TARGET_CC_MICROSOFT ! * #pragma mark ~ -> #pragma mark - ! * Added #ifdef PRAGMA_MARK ! * ! * Revision 1.8 2001/04/27 09:18:36 jesjones ! * Updated for the XTranscode changes. ! * ! * Revision 1.7 2001/04/21 03:31:48 jesjones ! * Updated for the new debug macros. ! * ! * Revision 1.6 2001/03/05 05:39:55 jesjones ! * Removed the dollar signs around the Log comment. ! * ! * Revision 1.5 2000/11/27 03:28:38 jesjones ! * GetTempFile takes an extension argument. GetTempFile increments the time instead of getting it anew each time through the loop. ! * ! * Revision 1.4 2000/11/25 01:47:38 jesjones ! * Fixed IsFAT. ! * ! * Revision 1.3 2000/11/20 05:37:43 jesjones ! * Added std:: to a few functions calls. ! * ! * Revision 1.2 2000/11/09 12:07:36 jesjones ! * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. ! * ! * <7> 4/02/02 JDJ DeleteFolder sets the current directory before calling RemoveDirectory. ! * <6> 12/12/99 JDJ GetValidName uses three periods instad of the bogus L"É" when ! * the name has to be shortened. ! * <5> 6/21/99 JDJ Added IsFAT and IsNTFS. IsValidChar allows printable Unicode ! * chars on NTFS. ! * <4> 5/07/99 JDJ Added IsWritable. ! * <3> 3/12/99 JDJ RenameFile and RenameFolder no longer modify the spec argument. ! * <2> 2/18/99 JDJ Fixed a bug that could cause GetValidName to index ! * past the end of the file name if the number of characters ! * to drop was odd. ! * <1> 1/10/98 JDJ Created (from Raven) ! */ ! ! #include <XWhisperHeader.h> ! #include <XFileSystem.h> ! ! #include <mmsystem.h> ! ! #include <WSystemInfo.h> ! #include <XDebug.h> ! #include <XExceptions.h> ! #include <XFolderSpec.h> ! #include <XStringUtils.h> ! ! namespace Whisper { ! ! ! // =================================================================================== ! // Helper Functions ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ! // EmptyFolder ! // ! // Deletes everything within the folder. ! // ! //--------------------------------------------------------------- ! static void EmptyFolder(const XFolderSpec& parent) ! { ! std::wstring searchString = parent.GetPath() + L"\\*.*"; ! ! HANDLE hand = nil; ! if (WSystemInfo::HasUnicode()) { ! WIN32_FIND_DATAW info; ! hand = ::FindFirstFileW(searchString.c_str(), &info); ! ThrowIfBadHandle(hand); ! ! int32 succeeded = true; ! while (succeeded) { ! if ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && info.cFileName[0] != '.') { ! XFolderSpec folder(parent, info.cFileName); ! XFileSystem::DeleteFolder(folder); ! ! } else if (info.cFileName[0] != '.') { ! XFileSpec file(parent, info.cFileName); ! XFileSystem::DeleteFile(file); ! } ! ! succeeded = ::FindNextFileW(hand, &info); ! } ! ! } else { ! WIN32_FIND_DATAA info; ! hand = ::FindFirstFileA(ToPlatformStr(searchString).c_str(), &info); ! ThrowIfBadHandle(hand); ! ! int32 succeeded = true; ! while (succeeded) { ! if ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && info.cFileName[0] != '.') { ! XFolderSpec folder(parent, FromPlatformStr(info.cFileName)); ! XFileSystem::DeleteFolder(folder); ! ! } else if (info.cFileName[0] != '.') { ! XFileSpec file(parent, FromPlatformStr(info.cFileName)); ! XFileSystem::DeleteFile(file); ! } ! ! succeeded = ::FindNextFileA(hand, &info); ! } ! } ! ! (void) ::FindClose(hand); ! } ! ! ! //--------------------------------------------------------------- ! // ! // IsValidChar ! // ! // This is from the InfoViewer topic "Long Filenames and the ! // Protected-Mode FAT File System" (it appears that these rules ! // also hold for NTFS). ! // ! //--------------------------------------------------------------- ! static bool IsValidChar(uint16 ch, bool hasUnicode) ! { ! bool valid = false; ! ! if (ch >= 'a' && ch <= 'z') ! valid = true; ! ! else if (ch >= 'A' && ch <= 'Z') ! valid = true; ! ! else if (ch >= '0' && ch <= '9') ! valid = true; ! ! else if (ch == ' ') ! valid = true; ! ! else if (hasUnicode && ch >= 128 && IsPrintable(ch)) ! valid = true; ! ! else if (!hasUnicode && ch >= 128 && ch <= 255) ! valid = true; ! ! else if (ch == '$' || ch == '%' || ch == '\'' || ch == '-' || ch == '_' || ! ch == '@' || ch == '~' || ch == '`' || ch == '!' || ch == '(' || ! ch == ')' || ch == '{' || ch == '}' || ch == '^' || ch == '#' || ! ch == '&' || ch == '+' || ch == ',' || ch == ';' || ch == '=' || ! ch == '[' || ch == ']') ! valid = true; ! ! return valid; ! } ! ! #if PRAGMA_MARK ! #pragma mark - ! #endif ! ! // =================================================================================== ! // class XFileSystem ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::CreateFolder [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::CreateFolder(const XFolderSpec& folder) ! { ! PRECONDITION(!XFileSystem::FolderExists(folder)); ! ! if (!XFileSystem::FolderExists(folder)) { ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::CreateDirectoryW(folder.GetPath().c_str(), nil); ! else ! succeeded = ::CreateDirectoryA(ToPlatformStr(folder.GetPath()).c_str(), nil); ! ThrowIf(!succeeded); ! } ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::RenameFolder [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::RenameFolder(const XFolderSpec& oldFolder, const std::wstring& inNewName) ! { ! PRECONDITION(XFileSystem::FolderExists(oldFolder)); ! PRECONDITION(inNewName.length() > 0); ! ! std::wstring newName = XFileSystem::GetValidName(inNewName, oldFolder.GetVolume()); ! ! XFolderSpec newFolder(oldFolder.GetParent(), newName); ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::MoveFileW(oldFolder.GetPath().c_str(), newFolder.GetPath().c_str()); ! else ! succeeded = ::MoveFileA(ToPlatformStr(oldFolder.GetPath()).c_str(), ToPlatformStr(newFolder.GetPath()).c_str()); ! ThrowIf(!succeeded); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::DeleteFolder [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::DeleteFolder(const XFolderSpec& folder) ! { ! PRECONDITION(XFileSystem::FolderExists(folder)); ! ! EmptyFolder(folder); ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) // if the current directory is "folder" RemoveDirectory will fail with a weird error message... ! succeeded = ::SetCurrentDirectoryW(folder.GetParent().GetPath().c_str()); ! else ! succeeded = ::SetCurrentDirectoryA(ToPlatformStr(folder.GetParent().GetPath()).c_str()); ! ThrowIf(!succeeded); ! ! if (WSystemInfo::HasUnicode()) ! succeeded = ::RemoveDirectoryW(folder.GetPath().c_str()); ! else ! succeeded = ::RemoveDirectoryA(ToPlatformStr(folder.GetPath()).c_str()); ! ThrowIf(!succeeded); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::FolderExists [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::FolderExists(const XFileSystemSpec& folder) ! { ! DWORD attributes; ! if (WSystemInfo::HasUnicode()) ! attributes = ::GetFileAttributesW(folder.GetPath().c_str()); ! else ! attributes = ::GetFileAttributesA(ToPlatformStr(folder.GetPath()).c_str()); ! ! bool exists = attributes != (DWORD) -1L && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; ! ! return exists; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetTempFolder [static] ! // ! //--------------------------------------------------------------- ! XFolderSpec XFileSystem::GetTempFolder(const std::wstring& prefix) ! { ! XFolderSpec tempItem; ! ! XFolderSpec tempFolder = XFolderSpec::GetTempFolder(); ! ! do { ! char buffer[32]; ! std::sprintf(buffer, "%d", timeGetTime()); ! ! std::wstring fileName = prefix + L" " + FromPlatformStr(buffer); ! fileName = XFileSystem::GetValidName(fileName, tempFolder.GetVolume()); // may need to truncate (this happens from the middle so we should exit the loop) ! ! tempItem = XFolderSpec(tempFolder, fileName); ! } while (XFileSystem::FolderExists(tempItem)); ! ! return tempItem; ! } ! ! #if PRAGMA_MARK ! #pragma mark - ! #endif ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::CreateFile [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::CreateFile(const XFileSpec& file, OSType creator, OSType fileType) ! { ! PRECONDITION(!XFileSystem::FileExists(file)); ! UNUSED(creator); ! UNUSED(fileType); ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::SetCurrentDirectoryW(file.GetParent().GetPath().c_str()); ! else ! succeeded = ::SetCurrentDirectoryA(ToPlatformStr(file.GetParent().GetPath()).c_str()); ! ThrowIf(!succeeded); ! ! HANDLE hand; ! if (WSystemInfo::HasUnicode()) ! hand = ::CreateFileW(file.GetName().c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nil); ! else ! hand = ::CreateFileA(ToPlatformStr(file.GetName()).c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nil); ! ThrowIfBadHandle(hand); ! ! succeeded = ::CloseHandle(hand); ! ThrowIf(!succeeded); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::RenameFile [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::RenameFile(const XFileSpec& oldFile, const std::wstring& inNewName) ! { ! PRECONDITION(XFileSystem::FileExists(oldFile)); ! PRECONDITION(inNewName.length() > 0); ! ! std::wstring newName = XFileSystem::GetValidName(inNewName, oldFile.GetVolume()); ! ! XFileSpec newFile(oldFile.GetParent(), newName); ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::MoveFileW(oldFile.GetPath().c_str(), newFile.GetPath().c_str()); ! else ! succeeded = ::MoveFileA(ToPlatformStr(oldFile.GetPath()).c_str(), ToPlatformStr(newFile.GetPath()).c_str()); ! ThrowIf(!succeeded); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::CopyFile [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::CopyFile(const XFileSpec& srcFile, const XFileSpec& dstFile, bool preflight) ! { ! UNUSED(preflight); ! ! #if _WIN32_WINNT >= 0x0400 ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::CopyFileExW(srcFile.GetPath().c_str(), // existing file ! dstFile.GetPath().c_str(), // new file ! nil, // progress routine ! nil, // refCon ! nil, // cancel flag ! COPY_FILE_FAIL_IF_EXISTS); // copy flags ! else ! succeeded = ::CopyFileExA(ToPlatformStr(srcFile.GetPath()), // existing file ! ToPlatformStr(dstFile.GetPath()), // new file ! nil, // progress routine ! nil, // refCon ! nil, // cancel flag ! COPY_FILE_FAIL_IF_EXISTS); // copy flags ! #else ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::CopyFileW(srcFile.GetPath().c_str(), // existing file ! dstFile.GetPath().c_str(), // new file ! true); // fail if new file exists ! else ! succeeded = ::CopyFileA(ToPlatformStr(srcFile.GetPath()).c_str(), // existing file ! ToPlatformStr(dstFile.GetPath()).c_str(), // new file ! true); // fail if new file exists ! #endif ! ! ThrowIf(!succeeded); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::DeleteFile [static] ! // ! //--------------------------------------------------------------- ! void XFileSystem::DeleteFile(const XFileSpec& file) ! { ! PRECONDITION(XFileSystem::FileExists(file)); ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::DeleteFileW(file.GetPath().c_str()); ! else ! succeeded = ::DeleteFileA(ToPlatformStr(file.GetPath()).c_str()); ! ThrowIf(!succeeded); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::FileExists [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::FileExists(const XFileSystemSpec& file) ! { ! DWORD attributes; ! if (WSystemInfo::HasUnicode()) ! attributes = ::GetFileAttributesW(file.GetPath().c_str()); ! else ! attributes = ::GetFileAttributesA(ToPlatformStr(file.GetPath()).c_str()); ! ! bool exists = attributes != (DWORD) -1L && (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; ! ! return exists; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsWritable [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsWritable(const XFileSpec& file) ! { ! bool writable = false; ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::SetCurrentDirectoryW(file.GetParent().GetPath().c_str()); ! else ! succeeded = ::SetCurrentDirectoryA(ToPlatformStr(file.GetParent().GetPath()).c_str()); ! ! if (succeeded) { ! HANDLE handle = nil; ! ! // File is writable if we can open it with write permission. ! if (WSystemInfo::HasUnicode()) ! handle = ::CreateFileW(file.GetName().c_str(), GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nil); ! else ! handle = ::CreateFileA(ToPlatformStr(file.GetName()).c_str(), GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nil); ! ! // If the file doesn't exist yet we need to make sure that ! // the volume isn't locked. ! if (handle == nil || handle == INVALID_HANDLE_VALUE) { ! if (WSystemInfo::HasUnicode()) ! handle = ::CreateFileW(file.GetName().c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, nil); ! else ! handle = ::CreateFileA(ToPlatformStr(file.GetName()).c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, nil); ! } ! ! if (handle != nil && handle != INVALID_HANDLE_VALUE) { ! writable = true; ! (void) ::CloseHandle(handle); ! } ! } ! ! return writable; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetFileSize [static] ! // ! //--------------------------------------------------------------- ! uint64 XFileSystem::GetFileSize(const XFileSpec& file) ! { ! uint64 bytes; ! ! HANDLE hand; ! if (WSystemInfo::HasUnicode()) { ! WIN32_FIND_DATAW info; ! hand = ::FindFirstFileW(file.GetPath().c_str(), &info); ! ThrowIfBadHandle(hand); ! ! bytes = info.nFileSizeHigh; ! bytes = (bytes << 32) + info.nFileSizeLow; ! ! } else { ! WIN32_FIND_DATAA info; ! hand = ::FindFirstFileA(ToPlatformStr(file.GetPath()).c_str(), &info); ! ThrowIfBadHandle(hand); ! ! bytes = info.nFileSizeHigh; ! bytes = (bytes << 32) + info.nFileSizeLow; ! } ! ! VERIFY(::FindClose(hand)); ! ! return bytes; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetTempFile [static] ! // ! // $$$ Might be better to use GetTempFileName, but the documentation ! // $$$ suggests that it doesn't take advantage of long file names. ! // $$$ But there is a GetTempFileName32... ! // ! //--------------------------------------------------------------- ! XFileSpec XFileSystem::GetTempFile(const std::wstring& prefix, const std::wstring& extension) ! { ! XFileSpec tempFile; ! ! XFolderSpec tempFolder = XFolderSpec::GetTempFolder(); ! ! uint32 time = timeGetTime(); ! ! do { ! char buffer[32]; ! std::sprintf(buffer, "%d", time++); ! ! std::wstring fileName = prefix + FromAsciiStr(buffer) + L"." + extension; ! fileName = XFileSystem::GetValidName(fileName, tempFolder.GetVolume()); // may need to truncate (this happens from the middle so we should exit the loop) ! ! tempFile = XFileSpec(tempFolder, fileName); ! } while (XFileSystem::SpecExists(tempFile)); ! ! return tempFile; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetUniqueFile [static] ! // ! //--------------------------------------------------------------- ! XFileSpec XFileSystem::GetUniqueFile(const XFileSpec& srcSpec) ! { ! XFileSpec dstSpec = srcSpec; ! ! if (XFileSystem::SpecExists(dstSpec)) { ! std::wstring dstName = srcSpec.GetName() + LoadWhisperString(L" copy (duplicate file)"); ! dstName = XFileSystem::GetValidName(dstName, dstSpec.GetVolume()); // truncate if need be ! dstSpec = XFileSpec(srcSpec.GetParent(), dstName); ! ! int32 count = 2; // Finder names the second copy "Hello copy 2" ! while (XFileSystem::SpecExists(dstSpec)) { ! char buffer[32]; ! std::sprintf(buffer, "%d", count++); ! ! std::wstring name = dstName + L" " + FromPlatformStr(buffer); ! name = XFileSystem::GetValidName(name, dstSpec.GetVolume()); // truncate if need be (this happens from the middle so we should exit the loop) ! ! dstSpec = XFileSpec(srcSpec.GetParent(), name); ! } ! } ! ! return dstSpec; ! } ! ! #if PRAGMA_MARK ! #pragma mark - ! #endif ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::SpecExists [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::SpecExists(const XFileSystemSpec& spec) ! { ! DWORD attributes; ! if (WSystemInfo::HasUnicode()) ! attributes = ::GetFileAttributesW(spec.GetPath().c_str()); ! else ! attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); ! ! return attributes != (DWORD) -1L; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsFile [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsFile(const XFileSystemSpec& spec) ! { ! bool isFile = false; ! ! DWORD attributes; ! if (WSystemInfo::HasUnicode()) ! attributes = ::GetFileAttributesW(spec.GetPath().c_str()); ! else ! attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); ! ! if (attributes != (DWORD) -1L) ! isFile = (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; ! ! return isFile; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsFolder [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsFolder(const XFileSystemSpec& spec) ! { ! bool isFolder = false; ! ! DWORD attributes; ! if (WSystemInfo::HasUnicode()) ! attributes = ::GetFileAttributesW(spec.GetPath().c_str()); ! else ! attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); ! ! if (attributes != (DWORD) -1L) ! isFolder = (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; ! ! return isFolder; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsReadOnly [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsReadOnly(const XFileSystemSpec& spec) ! { ! DWORD attributes; ! if (WSystemInfo::HasUnicode()) ! attributes = ::GetFileAttributesW(spec.GetPath().c_str()); ! else ! attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); ! ThrowIf(attributes == (DWORD) -1L); ! ! bool isFolder = (attributes & FILE_ATTRIBUTE_READONLY) != 0; ! ! return isFolder; ! } ! ! #if PRAGMA_MARK ! #pragma mark - ! #endif ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetVolumeTotalBytes [static] ! // ! //--------------------------------------------------------------- ! uint64 XFileSystem::GetVolumeTotalBytes(const OSVolume& volume) ! { ! std::wstring path = volume + L":\\"; ! ! ULARGE_INTEGER bytesAvail; // free bytes that user can use ! ULARGE_INTEGER totalBytes; // total bytes on drive ! ULARGE_INTEGER totalFreeBytes; // total free bytes on drive ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::GetDiskFreeSpaceExW(path.c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); ! else ! succeeded = ::GetDiskFreeSpaceExA(ToPlatformStr(path).c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); ! ThrowIf(!succeeded); ! ! uint64 bytes = totalBytes.HighPart; ! bytes = (bytes << 32) + totalBytes.LowPart; ! ! return bytes; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetVolumeFreeBytes [static] ! // ! //--------------------------------------------------------------- ! uint64 XFileSystem::GetVolumeFreeBytes(const OSVolume& volume) ! { ! std::wstring path = volume + L":\\"; ! ! ULARGE_INTEGER bytesAvail; // free bytes that user can use ! ULARGE_INTEGER totalBytes; // total bytes on drive ! ULARGE_INTEGER totalFreeBytes; // total free bytes on drive ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) ! succeeded = ::GetDiskFreeSpaceExW(path.c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); ! else ! succeeded = ::GetDiskFreeSpaceExA(ToPlatformStr(path).c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); ! ThrowIf(!succeeded); ! ! uint64 bytes = bytesAvail.HighPart; ! bytes = (bytes << 32) + bytesAvail.LowPart; ! ! return bytes; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetMaxFileSpecLength [static] ! // ! //--------------------------------------------------------------- ! uint32 XFileSystem::GetMaxFileSpecLength(const OSVolume& volume) ! { ! std::wstring path = volume + L":\\"; ! ! uint32 maxCompLen, attributes; ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) { ! wchar_t buffer[MAX_PATH + 1]; ! succeeded = ::GetVolumeInformationW(path.c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); ! ! } else { ! char buffer[MAX_PATH + 1]; ! succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); ! } ! ThrowIf(!succeeded); ! ! return maxCompLen; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetVolumeName [static] ! // ! //--------------------------------------------------------------- ! std::wstring XFileSystem::GetVolumeName(const OSVolume& volume) ! { ! std::wstring name; ! std::wstring path = volume + L":\\"; ! ! uint32 maxCompLen, attributes; ! ! int32 succeeded; ! if (WSystemInfo::HasUnicode()) { ! wchar_t buffer[MAX_PATH + 1]; ! succeeded = ::GetVolumeInformationW(path.c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); ! ! name = buffer; ! ! } else { ! char buffer[MAX_PATH + 1]; ! succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); ! ! name = FromPlatformStr(buffer); ! } ! ThrowIf(!succeeded); ! ! return name; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsFAT [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsFAT(const OSVolume& volume) ! { ! std::wstring path = volume + L":\\"; ! ! uint32 maxCompLen, attributes; ! ! char buffer[MAX_PATH + 1]; ! int32 succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), nil, 0, nil, &maxCompLen, &attributes, buffer, sizeof(buffer)); ! ThrowIf(!succeeded); ! ! bool is = ConvertToLowerCase(FromPlatformStr(buffer)) == L"fat" || ! ConvertToLowerCase(FromPlatformStr(buffer)) == L"fat32" ; // CodeWarrior doesn't have stricmp... ! ! return is; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsNTFS [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsNTFS(const OSVolume& volume) ! { ! std::wstring path = volume + L":\\"; ! ! uint32 maxCompLen, attributes; ! ! char buffer[MAX_PATH + 1]; ! int32 succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), nil, 0, nil, &maxCompLen, &attributes, buffer, sizeof(buffer)); ! ThrowIf(!succeeded); ! ! bool is = ConvertToLowerCase(FromPlatformStr(buffer)) == L"ntfs"; // CodeWarrior doesn't have stricmp... ! ! return is; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsNetworkVolume [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsNetworkVolume(const OSVolume& volume) ! { ! std::wstring path = volume + L":\\"; ! ! UINT type; ! if (WSystemInfo::HasUnicode()) ! type = ::GetDriveTypeW(path.c_str()); ! else ! type = ::GetDriveTypeA(ToPlatformStr(path).c_str()); ! ASSERT(type != 0); // can't be determined ! ASSERT(type != 1); // root directory doesn't exist ! ! bool isNetwork = type == DRIVE_REMOTE; ! ! return isNetwork; ! } ! ! #if PRAGMA_MARK ! #pragma mark - ! #endif ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::IsValidName [static] ! // ! //--------------------------------------------------------------- ! bool XFileSystem::IsValidName(const std::wstring& name, const OSVolume& volume) ! { ! uint32 maxLength = XFileSystem::GetMaxFileSpecLength(volume); ! ! bool valid = name.length() <= maxLength && name.length() > 0; ! ! if (valid) { ! bool hasUnicode = XFileSystem::IsNTFS(volume); ! ! for (uint32 index = 0; index < name.length() && valid; ++index) ! valid = IsValidChar(name[index], hasUnicode) || name[index] == '.'; ! ! // if (valid) ! // valid = Count(name, '.') <= 1; // can't have more than one period (this is apparently OK for folders, and maybe files?) ! } ! ! return valid; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XFileSystem::GetValidName [static] ! // ! //--------------------------------------------------------------- ! std::wstring XFileSystem::GetValidName(const std::wstring& name, const OSVolume& volume, uint32 maxLen) ! { ! PRECONDITION(name.length() >= 5); // need room for at least a character followed by a three letter extension ! ! uint32 max = XFileSystem::GetMaxFileSpecLength(volume); ! if (maxLen > max) ! maxLen = max; ! ! std::wstring outName = name; ! ! // Replace bad characters with dashes. ! bool hasUnicode = XFileSystem::IsNTFS(volume); ! ! uint32 index; ! for (index = 0; index < outName.length(); ++index) ! if (!IsValidChar(outName[index], hasUnicode) && outName[index] != ' ' && outName[index] != '.') ! outName[index] = '-'; ! ! uint32 numPeriods = Count(outName, '.'); ! if (numPeriods > 1) { ! for (index = 1; index < outName.length() && numPeriods > 1; ++index) { ! if (outName[index] == '.') { ! outName[index] = '-'; ! --numPeriods; ! } ! } ! } ! ! // Truncate from the middle if the name is too large. ! if (outName.length() > maxLen) { ! uint32 length = outName.length(); ! uint32 pos = outName.rfind('.'); ! if (pos != std::wstring::npos) ! length = pos; ! ! uint32 overflow = outName.length() - maxLen + 3; // add three for the periods ! ! uint32 first = (length - overflow)/2; // first character we're going to drop ! uint32 last = first + overflow - 1; // last character we're going to drop ! ! outName = outName.substr(0, first) + L"..." + outName.substr(last + 1); ! POSTCONDITION(outName.length() <= maxLen); ! } ! ! POSTCONDITION(XFileSystem::IsValidName(outName, volume)); ! ! return outName; ! } ! ! ! } // namespace Whisper --- 1,4 ---- ! /* * File: WFileSystem.cpp * Summary: Some handy functions for dealing with the file system. * Written by: Jesse Jones * * Copyright © 1998-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * $Log$ ! /* * File: WFileSystem.cpp * Summary: Some handy functions for dealing with the file system. * Written by: Jesse Jones * * Copyright © 1998-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Revision 1.10 2004/03/28 22:13:16 psnively ! /* * File: WFileSystem.cpp * Summary: Some handy functions for dealing with the file system. * Written by: Jesse Jones * * Copyright © 1998-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. ! /* * File: WFileSystem.cpp * Summary: Some handy functions for dealing with the file system. * Written by: Jesse Jones * * Copyright © 1998-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * * Revision 1.9 2003/08/15 09:57:52 meeroh * Macro changes: * MAC -> TARGET_OS_MAC * WIN -> TARGET_OS_WIN32 * TARGET_CARBON -> TARGET_API_MAC_CARBON * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN * CODE_WARRIOR -> TARGET_CC_METROWERKS * __MWERKS__ -> TARGET_CC_METROWERKS * MSVC -> TARGET_CC_MICROSOFT * _MSC_VER -> TARGET_CC_MICROSOFT * #pragma mark ~ -> #pragma mark - * Added #ifdef PRAGMA_MARK * * Revision 1.8 2001/04/27 09:18:36 jesjones * Updated for the XTranscode changes. * * Revision 1.7 2001/04/21 03:31:48 jesjones * Updated for the new debug macros. * * Revision 1.6 2001/03/05 05:39:55 jesjones * Removed the dollar signs around the Log comment. * * Revision 1.5 2000/11/27 03:28:38 jesjones * GetTempFile takes an extension argument. GetTempFile increments the time instead of getting it anew each time through the loop. * * Revision 1.4 2000/11/25 01:47:38 jesjones * Fixed IsFAT. * * Revision 1.3 2000/11/20 05:37:43 jesjones * Added std:: to a few functions calls. * * Revision 1.2 2000/11/09 12:07:36 jesjones * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. * * <7> 4/02/02 JDJ DeleteFolder sets the current directory before calling RemoveDirectory. * <6> 12/12/99 JDJ GetValidName uses three periods instad of the bogus L"É" when * the name has to be shortened. * <5> 6/21/99 JDJ Added IsFAT and IsNTFS. IsValidChar allows printable Unicode * chars on NTFS. * <4> 5/07/99 JDJ Added IsWritable. * <3> 3/12/99 JDJ RenameFile and RenameFolder no longer modify the spec argument. * <2> 2/18/99 JDJ Fixed a bug that could cause GetValidName to index * past the end of the file name if the number of characters * to drop was odd. * <1> 1/10/98 JDJ Created (from Raven) */ #include <XWhisperHeader.h> #include <XFileSystem.h> #include <mmsystem.h> #include <WSystemInfo.h> #include <XDebug.h> #include <XExceptions.h> #include <XFolderSpec.h> #include <XStringUtils.h> namespace Whisper { // =================================================================================== // Helper Functions // =================================================================================== //--------------------------------------------------------------- // // EmptyFolder // // Deletes everything within the folder. // //--------------------------------------------------------------- static void EmptyFolder(const XFolderSpec& parent) { std::wstring searchString = parent.GetPath() + L"\\*.*"; HANDLE hand = nil; if (WSystemInfo::HasUnicode()) { WIN32_FIND_DATAW info; hand = ::FindFirstFileW(searchString.c_str(), &info); ThrowIfBadHandle(hand); int32 succeeded = true; while (succeeded) { if ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && info.cFileName[0] != '.') { XFolderSpec folder(parent, info.cFileName); XFileSystem::DeleteFolder(folder); } else if (info.cFileName[0] != '.') { XFileSpec file(parent, info.cFileName); XFileSystem::DeleteFile(file); } succeeded = ::FindNextFileW(hand, &info); } } else { WIN32_FIND_DATAA info; hand = ::FindFirstFileA(ToPlatformStr(searchString).c_str(), &info); ThrowIfBadHandle(hand); int32 succeeded = true; while (succeeded) { if ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && info.cFileName[0] != '.') { XFolderSpec folder(parent, FromPlatformStr(info.cFileName)); XFileSystem::DeleteFolder(folder); } else if (info.cFileName[0] != '.') { XFileSpec file(parent, FromPlatformStr(info.cFileName)); XFileSystem::DeleteFile(file); } succeeded = ::FindNextFileA(hand, &info); } } (void) ::FindClose(hand); } //--------------------------------------------------------------- // // IsValidChar // // This is from the InfoViewer topic "Long Filenames and the // Protected-Mode FAT File System" (it appears that these rules // also hold for NTFS). // //--------------------------------------------------------------- static bool IsValidChar(uint16 ch, bool hasUnicode) { bool valid = false; if (ch >= 'a' && ch <= 'z') valid = true; else if (ch >= 'A' && ch <= 'Z') valid = true; else if (ch >= '0' && ch <= '9') valid = true; else if (ch == ' ') valid = true; else if (hasUnicode && ch >= 128 && IsPrintable(ch)) valid = true; else if (!hasUnicode && ch >= 128 && ch <= 255) valid = true; else if (ch == '$' || ch == '%' || ch == '\'' || ch == '-' || ch == '_' || ch == '@' || ch == '~' || ch == '`' || ch == '!' || ch == '(' || ch == ')' || ch == '{' || ch == '}' || ch == '^' || ch == '#' || ch == '&' || ch == '+' || ch == ',' || ch == ';' || ch == '=' || ch == '[' || ch == ']') valid = true; return valid; } #if PRAGMA_MARK #pragma mark - #endif // =================================================================================== // class XFileSystem // =================================================================================== //--------------------------------------------------------------- // // XFileSystem::CreateFolder [static] // //--------------------------------------------------------------- void XFileSystem::CreateFolder(const XFolderSpec& folder) { PRECONDITION(!XFileSystem::FolderExists(folder)); if (!XFileSystem::FolderExists(folder)) { int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::CreateDirectoryW(folder.GetPath().c_str(), nil); else succeeded = ::CreateDirectoryA(ToPlatformStr(folder.GetPath()).c_str(), nil); ThrowIf(!succeeded); } } //--------------------------------------------------------------- // // XFileSystem::RenameFolder [static] // //--------------------------------------------------------------- void XFileSystem::RenameFolder(const XFolderSpec& oldFolder, const std::wstring& inNewName) { PRECONDITION(XFileSystem::FolderExists(oldFolder)); PRECONDITION(inNewName.length() > 0); std::wstring newName = XFileSystem::GetValidName(inNewName, oldFolder.GetVolume()); XFolderSpec newFolder(oldFolder.GetParent(), newName); int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::MoveFileW(oldFolder.GetPath().c_str(), newFolder.GetPath().c_str()); else succeeded = ::MoveFileA(ToPlatformStr(oldFolder.GetPath()).c_str(), ToPlatformStr(newFolder.GetPath()).c_str()); ThrowIf(!succeeded); } //--------------------------------------------------------------- // // XFileSystem::DeleteFolder [static] // //--------------------------------------------------------------- void XFileSystem::DeleteFolder(const XFolderSpec& folder) { PRECONDITION(XFileSystem::FolderExists(folder)); EmptyFolder(folder); int32 succeeded; if (WSystemInfo::HasUnicode()) // if the current directory is "folder" RemoveDirectory will fail with a weird error message... succeeded = ::SetCurrentDirectoryW(folder.GetParent().GetPath().c_str()); else succeeded = ::SetCurrentDirectoryA(ToPlatformStr(folder.GetParent().GetPath()).c_str()); ThrowIf(!succeeded); if (WSystemInfo::HasUnicode()) succeeded = ::RemoveDirectoryW(folder.GetPath().c_str()); else succeeded = ::RemoveDirectoryA(ToPlatformStr(folder.GetPath()).c_str()); ThrowIf(!succeeded); } //--------------------------------------------------------------- // // XFileSystem::FolderExists [static] // //--------------------------------------------------------------- bool XFileSystem::FolderExists(const XFileSystemSpec& folder) { DWORD attributes; if (WSystemInfo::HasUnicode()) attributes = ::GetFileAttributesW(folder.GetPath().c_str()); else attributes = ::GetFileAttributesA(ToPlatformStr(folder.GetPath()).c_str()); bool exists = attributes != (DWORD) -1L && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; return exists; } //--------------------------------------------------------------- // // XFileSystem::GetTempFolder [static] // //--------------------------------------------------------------- XFolderSpec XFileSystem::GetTempFolder(const std::wstring& prefix) { XFolderSpec tempItem; XFolderSpec tempFolder = XFolderSpec::GetTempFolder(); do { char buffer[32]; std::sprintf(buffer, "%d", timeGetTime()); std::wstring fileName = prefix + L" " + FromPlatformStr(buffer); fileName = XFileSystem::GetValidName(fileName, tempFolder.GetVolume()); // may need to truncate (this happens from the middle so we should exit the loop) tempItem = XFolderSpec(tempFolder, fileName); } while (XFileSystem::FolderExists(tempItem)); return tempItem; } #if PRAGMA_MARK #pragma mark - #endif //--------------------------------------------------------------- // // XFileSystem::CreateFile [static] // //--------------------------------------------------------------- void XFileSystem::CreateFile(const XFileSpec& file, OSType creator, OSType fileType) { PRECONDITION(!XFileSystem::FileExists(file)); UNUSED(creator); UNUSED(fileType); int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::SetCurrentDirectoryW(file.GetParent().GetPath().c_str()); else succeeded = ::SetCurrentDirectoryA(ToPlatformStr(file.GetParent().GetPath()).c_str()); ThrowIf(!succeeded); HANDLE hand; if (WSystemInfo::HasUnicode()) hand = ::CreateFileW(file.GetName().c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nil); else hand = ::CreateFileA(ToPlatformStr(file.GetName()).c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nil); ThrowIfBadHandle(hand); succeeded = ::CloseHandle(hand); ThrowIf(!succeeded); } //--------------------------------------------------------------- // // XFileSystem::RenameFile [static] // //--------------------------------------------------------------- void XFileSystem::RenameFile(const XFileSpec& oldFile, const std::wstring& inNewName) { PRECONDITION(XFileSystem::FileExists(oldFile)); PRECONDITION(inNewName.length() > 0); std::wstring newName = XFileSystem::GetValidName(inNewName, oldFile.GetVolume()); XFileSpec newFile(oldFile.GetParent(), newName); int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::MoveFileW(oldFile.GetPath().c_str(), newFile.GetPath().c_str()); else succeeded = ::MoveFileA(ToPlatformStr(oldFile.GetPath()).c_str(), ToPlatformStr(newFile.GetPath()).c_str()); ThrowIf(!succeeded); } //--------------------------------------------------------------- // // XFileSystem::CopyFile [static] // //--------------------------------------------------------------- void XFileSystem::CopyFile(const XFileSpec& srcFile, const XFileSpec& dstFile) { #if _WIN32_WINNT >= 0x0400 int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::CopyFileExW(srcFile.GetPath().c_str(), // existing file dstFile.GetPath().c_str(), // new file nil, // progress routine nil, // refCon nil, // cancel flag COPY_FILE_FAIL_IF_EXISTS); // copy flags else succeeded = ::CopyFileExA(ToPlatformStr(srcFile.GetPath()), // existing file ToPlatformStr(dstFile.GetPath()), // new file nil, // progress routine nil, // refCon nil, // cancel flag COPY_FILE_FAIL_IF_EXISTS); // copy flags #else int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::CopyFileW(srcFile.GetPath().c_str(), // existing file dstFile.GetPath().c_str(), // new file true); // fail if new file exists else succeeded = ::CopyFileA(ToPlatformStr(srcFile.GetPath()).c_str(), // existing file ToPlatformStr(dstFile.GetPath()).c_str(), // new file true); // fail if new file exists #endif ThrowIf(!succeeded); } //--------------------------------------------------------------- // // XFileSystem::DeleteFile [static] // //--------------------------------------------------------------- void XFileSystem::DeleteFile(const XFileSpec& file) { PRECONDITION(XFileSystem::FileExists(file)); int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::DeleteFileW(file.GetPath().c_str()); else succeeded = ::DeleteFileA(ToPlatformStr(file.GetPath()).c_str()); ThrowIf(!succeeded); } //--------------------------------------------------------------- // // XFileSystem::FileExists [static] // //--------------------------------------------------------------- bool XFileSystem::FileExists(const XFileSystemSpec& file) { DWORD attributes; if (WSystemInfo::HasUnicode()) attributes = ::GetFileAttributesW(file.GetPath().c_str()); else attributes = ::GetFileAttributesA(ToPlatformStr(file.GetPath()).c_str()); bool exists = attributes != (DWORD) -1L && (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; return exists; } //--------------------------------------------------------------- // // XFileSystem::IsWritable [static] // //--------------------------------------------------------------- bool XFileSystem::IsWritable(const XFileSpec& file) { bool writable = false; int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::SetCurrentDirectoryW(file.GetParent().GetPath().c_str()); else succeeded = ::SetCurrentDirectoryA(ToPlatformStr(file.GetParent().GetPath()).c_str()); if (succeeded) { HANDLE handle = nil; // File is writable if we can open it with write permission. if (WSystemInfo::HasUnicode()) handle = ::CreateFileW(file.GetName().c_str(), GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nil); else handle = ::CreateFileA(ToPlatformStr(file.GetName()).c_str(), GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nil); // If the file doesn't exist yet we need to make sure that // the volume isn't locked. if (handle == nil || handle == INVALID_HANDLE_VALUE) { if (WSystemInfo::HasUnicode()) handle = ::CreateFileW(file.GetName().c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, nil); else handle = ::CreateFileA(ToPlatformStr(file.GetName()).c_str(), GENERIC_WRITE, 0, nil, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, nil); } if (handle != nil && handle != INVALID_HANDLE_VALUE) { writable = true; (void) ::CloseHandle(handle); } } return writable; } //--------------------------------------------------------------- // // XFileSystem::GetFileSize [static] // //--------------------------------------------------------------- uint64 XFileSystem::GetFileSize(const XFileSpec& file) { uint64 bytes; HANDLE hand; if (WSystemInfo::HasUnicode()) { WIN32_FIND_DATAW info; hand = ::FindFirstFileW(file.GetPath().c_str(), &info); ThrowIfBadHandle(hand); bytes = info.nFileSizeHigh; bytes = (bytes << 32) + info.nFileSizeLow; } else { WIN32_FIND_DATAA info; hand = ::FindFirstFileA(ToPlatformStr(file.GetPath()).c_str(), &info); ThrowIfBadHandle(hand); bytes = info.nFileSizeHigh; bytes = (bytes << 32) + info.nFileSizeLow; } VERIFY(::FindClose(hand)); return bytes; } //--------------------------------------------------------------- // // XFileSystem::GetTempFile [static] // // $$$ Might be better to use GetTempFileName, but the documentation // $$$ suggests that it doesn't take advantage of long file names. // $$$ But there is a GetTempFileName32... // //--------------------------------------------------------------- XFileSpec XFileSystem::GetTempFile(const std::wstring& prefix, const std::wstring& extension) { XFileSpec tempFile; XFolderSpec tempFolder = XFolderSpec::GetTempFolder(); uint32 time = timeGetTime(); do { char buffer[32]; std::sprintf(buffer, "%d", time++); std::wstring fileName = prefix + FromAsciiStr(buffer) + L"." + extension; fileName = XFileSystem::GetValidName(fileName, tempFolder.GetVolume()); // may need to truncate (this happens from the middle so we should exit the loop) tempFile = XFileSpec(tempFolder, fileName); } while (XFileSystem::SpecExists(tempFile)); return tempFile; } //--------------------------------------------------------------- // // XFileSystem::GetUniqueFile [static] // //--------------------------------------------------------------- XFileSpec XFileSystem::GetUniqueFile(const XFileSpec& srcSpec) { XFileSpec dstSpec = srcSpec; if (XFileSystem::SpecExists(dstSpec)) { std::wstring dstName = srcSpec.GetName() + LoadWhisperString(L" copy (duplicate file)"); dstName = XFileSystem::GetValidName(dstName, dstSpec.GetVolume()); // truncate if need be dstSpec = XFileSpec(srcSpec.GetParent(), dstName); int32 count = 2; // Finder names the second copy "Hello copy 2" while (XFileSystem::SpecExists(dstSpec)) { char buffer[32]; std::sprintf(buffer, "%d", count++); std::wstring name = dstName + L" " + FromPlatformStr(buffer); name = XFileSystem::GetValidName(name, dstSpec.GetVolume()); // truncate if need be (this happens from the middle so we should exit the loop) dstSpec = XFileSpec(srcSpec.GetParent(), name); } } return dstSpec; } #if PRAGMA_MARK #pragma mark - #endif //--------------------------------------------------------------- // // XFileSystem::SpecExists [static] // //--------------------------------------------------------------- bool XFileSystem::SpecExists(const XFileSystemSpec& spec) { DWORD attributes; if (WSystemInfo::HasUnicode()) attributes = ::GetFileAttributesW(spec.GetPath().c_str()); else attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); return attributes != (DWORD) -1L; } //--------------------------------------------------------------- // // XFileSystem::IsFile [static] // //--------------------------------------------------------------- bool XFileSystem::IsFile(const XFileSystemSpec& spec) { bool isFile = false; DWORD attributes; if (WSystemInfo::HasUnicode()) attributes = ::GetFileAttributesW(spec.GetPath().c_str()); else attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); if (attributes != (DWORD) -1L) isFile = (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0; return isFile; } //--------------------------------------------------------------- // // XFileSystem::IsFolder [static] // //--------------------------------------------------------------- bool XFileSystem::IsFolder(const XFileSystemSpec& spec) { bool isFolder = false; DWORD attributes; if (WSystemInfo::HasUnicode()) attributes = ::GetFileAttributesW(spec.GetPath().c_str()); else attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); if (attributes != (DWORD) -1L) isFolder = (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; return isFolder; } //--------------------------------------------------------------- // // XFileSystem::IsReadOnly [static] // //--------------------------------------------------------------- bool XFileSystem::IsReadOnly(const XFileSystemSpec& spec) { DWORD attributes; if (WSystemInfo::HasUnicode()) attributes = ::GetFileAttributesW(spec.GetPath().c_str()); else attributes = ::GetFileAttributesA(ToPlatformStr(spec.GetPath()).c_str()); ThrowIf(attributes == (DWORD) -1L); bool isFolder = (attributes & FILE_ATTRIBUTE_READONLY) != 0; return isFolder; } #if PRAGMA_MARK #pragma mark - #endif //--------------------------------------------------------------- // // XFileSystem::GetVolumeTotalBytes [static] // //--------------------------------------------------------------- uint64 XFileSystem::GetVolumeTotalBytes(const OSVolume& volume) { std::wstring path = volume + L":\\"; ULARGE_INTEGER bytesAvail; // free bytes that user can use ULARGE_INTEGER totalBytes; // total bytes on drive ULARGE_INTEGER totalFreeBytes; // total free bytes on drive int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::GetDiskFreeSpaceExW(path.c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); else succeeded = ::GetDiskFreeSpaceExA(ToPlatformStr(path).c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); ThrowIf(!succeeded); uint64 bytes = totalBytes.HighPart; bytes = (bytes << 32) + totalBytes.LowPart; return bytes; } //--------------------------------------------------------------- // // XFileSystem::GetVolumeFreeBytes [static] // //--------------------------------------------------------------- uint64 XFileSystem::GetVolumeFreeBytes(const OSVolume& volume) { std::wstring path = volume + L":\\"; ULARGE_INTEGER bytesAvail; // free bytes that user can use ULARGE_INTEGER totalBytes; // total bytes on drive ULARGE_INTEGER totalFreeBytes; // total free bytes on drive int32 succeeded; if (WSystemInfo::HasUnicode()) succeeded = ::GetDiskFreeSpaceExW(path.c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); else succeeded = ::GetDiskFreeSpaceExA(ToPlatformStr(path).c_str(), &bytesAvail, &totalBytes, &totalFreeBytes); ThrowIf(!succeeded); uint64 bytes = bytesAvail.HighPart; bytes = (bytes << 32) + bytesAvail.LowPart; return bytes; } //--------------------------------------------------------------- // // XFileSystem::GetMaxFileSpecLength [static] // //--------------------------------------------------------------- uint32 XFileSystem::GetMaxFileSpecLength(const OSVolume& volume) { std::wstring path = volume + L":\\"; uint32 maxCompLen, attributes; int32 succeeded; if (WSystemInfo::HasUnicode()) { wchar_t buffer[MAX_PATH + 1]; succeeded = ::GetVolumeInformationW(path.c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); } else { char buffer[MAX_PATH + 1]; succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); } ThrowIf(!succeeded); return maxCompLen; } //--------------------------------------------------------------- // // XFileSystem::GetVolumeName [static] // //--------------------------------------------------------------- std::wstring XFileSystem::GetVolumeName(const OSVolume& volume) { std::wstring name; std::wstring path = volume + L":\\"; uint32 maxCompLen, attributes; int32 succeeded; if (WSystemInfo::HasUnicode()) { wchar_t buffer[MAX_PATH + 1]; succeeded = ::GetVolumeInformationW(path.c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); name = buffer; } else { char buffer[MAX_PATH + 1]; succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), buffer, sizeof(buffer), nil, &maxCompLen, &attributes, nil, 0); name = FromPlatformStr(buffer); } ThrowIf(!succeeded); return name; } //--------------------------------------------------------------- // // XFileSystem::IsFAT [static] // //--------------------------------------------------------------- bool XFileSystem::IsFAT(const OSVolume& volume) { std::wstring path = volume + L":\\"; uint32 maxCompLen, attributes; char buffer[MAX_PATH + 1]; int32 succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), nil, 0, nil, &maxCompLen, &attributes, buffer, sizeof(buffer)); ThrowIf(!succeeded); bool is = ConvertToLowerCase(FromPlatformStr(buffer)) == L"fat" || ConvertToLowerCase(FromPlatformStr(buffer)) == L"fat32" ; // CodeWarrior doesn't have stricmp... return is; } //--------------------------------------------------------------- // // XFileSystem::IsNTFS [static] // //--------------------------------------------------------------- bool XFileSystem::IsNTFS(const OSVolume& volume) { std::wstring path = volume + L":\\"; uint32 maxCompLen, attributes; char buffer[MAX_PATH + 1]; int32 succeeded = ::GetVolumeInformationA(ToPlatformStr(path).c_str(), nil, 0, nil, &maxCompLen, &attributes, buffer, sizeof(buffer)); ThrowIf(!succeeded); bool is = ConvertToLowerCase(FromPlatformStr(buffer)) == L"ntfs"; // CodeWarrior doesn't have stricmp... return is; } //--------------------------------------------------------------- // // XFileSystem::IsNetworkVolume [static] // //--------------------------------------------------------------- bool XFileSystem::IsNetworkVolume(const OSVolume& volume) { std::wstring path = volume + L":\\"; UINT type; if (WSystemInfo::HasUnicode()) type = ::GetDriveTypeW(path.c_str()); else type = ::GetDriveTypeA(ToPlatformStr(path).c_str()); ASSERT(type != 0); // can't be determined ASSERT(type != 1); // root directory doesn't exist bool isNetwork = type == DRIVE_REMOTE; return isNetwork; } #if PRAGMA_MARK #pragma mark - #endif //--------------------------------------------------------------- // // XFileSystem::IsValidName [static] // //--------------------------------------------------------------- bool XFileSystem::IsValidName(const std::wstring& name, const OSVolume& volume) { uint32 maxLength = XFileSystem::GetMaxFileSpecLength(volume); bool valid = name.length() <= maxLength && name.length() > 0; if (valid) { bool hasUnicode = XFileSystem::IsNTFS(volume); for (uint32 index = 0; index < name.length() && valid; ++index) valid = IsValidChar(name[index], hasUnicode) || name[index] == '.'; // if (valid) // valid = Count(name, '.') <= 1; // can't have more than one period (this is apparently OK for folders, and maybe files?) } return valid; } //--------------------------------------------------------------- // // XFileSystem::GetValidName [static] // //--------------------------------------------------------------- std::wstring XFileSystem::GetValidName(const std::wstring& name, const OSVolume& volume, uint32 maxLen) { PRECONDITION(name.length() >= 5); // need room for at least a character followed by a three letter extension uint32 max = XFileSystem::GetMaxFileSpecLength(volume); if (maxLen > max) maxLen = max; std::wstring outName = name; // Replace bad characters with dashes. bool hasUnicode = XFileSystem::IsNTFS(volume); uint32 index; for (index = 0; index < outName.length(); ++index) if (!IsValidChar(outName[index], hasUnicode) && outName[index] != ' ' && outName[index] != '.') outName[index] = '-'; uint32 numPeriods = Count(outName, '.'); if (numPeriods > 1) { for (index = 1; index < outName.length() && numPeriods > 1; ++index) { if (outName[index] == '.') { outName[index] = '-'; --numPeriods; } } } // Truncate from the middle if the name is too large. if (outName.length() > maxLen) { uint32 length = outName.length(); uint32 pos = outName.rfind('.'); if (pos != std::wstring::npos) length = pos; uint32 overflow = outName.length() - maxLen + 3; // add three for the periods uint32 first = (length - overflow)/2; // first character we're going to drop uint32 last = first + overflow - 1; // last character we're going to drop outName = outName.substr(0, first) + L"..." + outName.substr(last + 1); POSTCONDITION(outName.length() <= maxLen); } POSTCONDITION(XFileSystem::IsValidName(outName, volume)); return outName; } } // namespace Whisper \ No newline at end of file Index: WMemoryMappedFile.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Win/WMemoryMappedFile.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WMemoryMappedFile.cpp 15 Aug 2003 09:58:27 -0000 1.7 --- WMemoryMappedFile.cpp 28 Mar 2004 22:13:16 -0000 1.8 *************** *** 1,501 **** ! /* ! * File: WMemoryMappedFile.cpp ! * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. ! * Written by: Jesse Jones ! * ! * Copyright © 1999-2001 Jesse Jones. ! * This code is distributed under the zlib/libpng license (see License.txt for details). ! * ! * Change History (most recent first): ! * ! * $Log$ ! * Revision 1.7 2003/08/15 09:58:27 meeroh ! * Macro changes: ! * MAC -> TARGET_OS_MAC ! * WIN -> TARGET_OS_WIN32 ! * TARGET_CARBON -> TARGET_API_MAC_CARBON ! * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN ! * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN ! * CODE_WARRIOR -> TARGET_CC_METROWERKS ! * __MWERKS__ -> TARGET_CC_METROWERKS ! * MSVC -> TARGET_CC_MICROSOFT ! * _MSC_VER -> TARGET_CC_MICROSOFT ! * #pragma mark ~ -> #pragma mark - ! * Added #ifdef PRAGMA_MARK ! * ! * Revision 1.6 2001/04/27 09:19:08 jesjones ! * Updated for the XTranscode changes. ! * ! * Revision 1.5 2001/04/21 03:32:34 jesjones ! * Updated for the new debug macros. ! * ! * Revision 1.4 2001/04/17 01:42:09 jesjones ! * Got rid of XInvariantMixin. ! * ! * Revision 1.3 2000/12/10 04:07:02 jesjones ! * Replaced int16_cast, uint32_cast, etc with numeric_cast. ! * ! * Revision 1.2 2000/11/09 12:10:02 jesjones ! * 1) Removed double CRs introduced during the initial checkin. 2) Chang... [truncated message content] |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:13
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Files/Source/Files Modified Files: XFileSystemSpec.h XMemoryMappedFile.h Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: XFileSystemSpec.h =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/XFileSystemSpec.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XFileSystemSpec.h 15 Aug 2003 10:05:15 -0000 1.6 --- XFileSystemSpec.h 28 Mar 2004 22:13:16 -0000 1.7 *************** *** 1,231 **** ! /* ! * File: XFileSystemSpec.h ! * Summary: An object that points to a (possibly non-existent) file/folder. ! * Written by: Jesse Jones ! * ! * Copyright © 1998-1999 Jesse Jones. ! * This code is distributed under the zlib/libpng license (see License.txt for details). ! * ! * Change History (most recent first): ! * ! * $Log$ ! * Revision 1.6 2003/08/15 10:05:15 meeroh ! * Macro changes: ! * MAC -> TARGET_OS_MAC ! * WIN -> TARGET_OS_WIN32 ! * TARGET_CARBON -> TARGET_API_MAC_CARBON ! * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN ! * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN ! * CODE_WARRIOR -> TARGET_CC_METROWERKS ! * __MWERKS__ -> TARGET_CC_METROWERKS ! * MSVC -> TARGET_CC_MICROSOFT ! * _MSC_VER -> TARGET_CC_MICROSOFT ! * #pragma mark ~ -> #pragma mark - ! * Added #ifdef PRAGMA_MARK ! * ! * Revision 1.5 2003/08/14 06:01:31 meeroh ! * Replaced FSSpecs with CFURLs/FSRefs ! * ! * Revision 1.4 2001/03/05 05:41:34 jesjones ! * Removed the dollar signs around the Log comment. ! * ! * Revision 1.3 2000/12/10 08:52:30 jesjones ! * Converted header comments to Doxygen format. ! * ! * Revision 1.2 2000/11/09 12:35:57 jesjones ! * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. ! */ ! ! #pragma once ! ! #if TARGET_OS_MAC ! #include <Aliases.h> ! #include <Files.h> ! #include <Resources.h> ! #endif ! ! #include <XTypes.h> ! ! namespace Whisper { ! ! #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED ! #pragma export on ! #endif ! ! ! //----------------------------------- ! // Forward References ! // ! class XFolderSpec; ! class XInStream; ! class XOutStream; ! ! ! // =================================================================================== ! // class XFileSystemSpec ! //! An object that points to a (possibly non-existent) file/folder. ! // =================================================================================== ! class FILES_EXPORT XFileSystemSpec { ! ! //----------------------------------- ! // Initialization/Destruction ! // ! public: ! virtual ~XFileSystemSpec(); ! ! XFileSystemSpec(); ! /**< Points to a bogus file. */ ! ! XFileSystemSpec(const OSFSSpec& spec); ! ! XFileSystemSpec(const XFolderSpec& folder, const std::wstring& fileName); ! ! #if TARGET_OS_MAC ! XFileSystemSpec(int16 volume, int32 parID, const std::wstring& fileName); ! ! XFileSystemSpec(const FSSpec& spec); ! ! XFileSystemSpec(const FSRef& ref); ! ! XFileSystemSpec(AliasHandle alias); ! ! explicit XFileSystemSpec(ResID aliasID); ! ! explicit XFileSystemSpec(const std::wstring& path); ! #endif ! ! //----------------------------------- ! // API ! // ! public: ! //! @name Conversion Operators ! //@{ ! // OSFSSpec& GetOSSpec() {return mSpec;} ! ! const OSFSSpec& GetOSSpec() const {return mSpec;} ! //@} ! ! //! @name Comparisons ! //@{ ! bool operator==(const XFileSystemSpec& rhs) const; ! ! bool operator!=(const XFileSystemSpec& rhs) const {return !this->operator==(rhs);} ! //@} ! ! //! @name Information ! //@{ ! std::wstring GetName() const; ! /**< Returns the name of the file/folder. */ ! ! std::wstring GetPrefix() const; ! /**< Returns the name sans extension. */ ! ! std::wstring GetExtension() const; ! /**< Returns the text after the last period (may be empty). ! Note that extensions are always returned as lower case. */ ! ! XFolderSpec GetParent() const; ! ! bool Exists () const; ! /**< Returnes true if this represents an existent file or folder */ ! ! OSVolume GetVolume() const; ! ! std::wstring GetPath() const; ! ! #if TARGET_OS_MAC ! MCFURL GetCFURL() const {return MCFURL(*mSpec, false);} ! ! const FSRef& GetFSRef() const; ! /**< Returns the FSRef if this represenents an existent file or folder */ ! ! FSSpec GetFSSpec() const; ! /**< Returns the FSSpec if this represenents an existent file or folder */ ! ! void ! GetCatalogInfo( ! FSCatalogInfoBitmap whichInfo, ! FSCatalogInfo* catalogInfo, ! HFSUniStr255* outName, ! FSSpec* fsSpec, ! FSRef* parentRef) const; ! /**< Gets catalog info if this represenents an existent file or folder, throws otherwise */ ! ! OSErr ! GetCatalogInfoErr( ! FSCatalogInfoBitmap whichInfo, ! FSCatalogInfo* catalogInfo, ! HFSUniStr255* outName, ! FSSpec* fsSpec, ! FSRef* parentRef) const; ! /**< Gets catalog info if this represenents an existent file or folder, returns error otherwise */ ! ! void ! SetCatalogInfo( ! FSCatalogInfoBitmap whichInfo, ! FSCatalogInfo* catalogInfo) const; ! /**< Sets catalog info if this represenents an existent file or folder, throws otherwise */ ! #endif ! //@} ! ! //! @name Streaming ! //@{ ! friend XInStream& operator>>(XInStream& stream, XFileSystemSpec& value); ! ! friend XOutStream& operator<<(XOutStream& stream, const XFileSystemSpec& value); ! //@} ! ! //----------------------------------- ! // Member Data ! // ! protected: ! #if TARGET_OS_MAC ! // On Mac OS, we can have the file spec, or the file ref, or both ! // Since converting from one to the other could be expensive, we create ! // them lazily. Calling GetOSSpec or GetFSRef may cause us to update ! // one or the other ! mutable OSFSSpec mSpec; ! ! // We cache the FSRef because it's expensive to convert ! // a CFURL to an FSRef ! mutable FSRef mFSRef; ! mutable bool mHaveFSRef; ! ! void InitWithOSFSSpec (const OSFSSpec& inSpec); ! void InitWithFSRef (const FSRef& inFSRef); ! void UpdateFSRef () const; ! void ClearFSRef () const; ! #endif ! ! #if TARGET_OS_WIN32 ! OSFSSpec mSpec; ! ! mutable std::wstring mLongName; ! #endif ! }; ! ! ! // =================================================================================== ! // Exception helpers ! // ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ThrowFileErr ! // ! FILES_EXPORT void ThrowFileErr(const XFileSystemSpec& spec, OSStatus err); ! ! //--------------------------------------------------------------- ! // ThrowIfFileErr ! // ! inline void ThrowIfFileErr(const XFileSystemSpec& spec, OSStatus err) ! { ! if (err != noErr) ! ThrowFileErr(spec, err); ! } ! ! #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED ! #pragma export reset ! #endif ! ! } // namespace Whisper --- 1,4 ---- ! /* * File: XFileSystemSpec.h * Summary: An object that points to a (possibly non-existent) file/folder. * Written by: Jesse Jones * * Copyright © 1998-1999 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * $Log$ ! /* * File: XFileSystemSpec.h * Summary: An object that points to a (possibly non-existent) file/folder. * Written by: Jesse Jones * * Copyright © 1998-1999 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Revision 1.7 2004/03/28 22:13:16 psnively ! /* * File: XFileSystemSpec.h * Summary: An object that points to a (possibly non-existent) file/folder. * Written by: Jesse Jones * * Copyright © 1998-1999 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. ! /* * File: XFileSystemSpec.h * Summary: An object that points to a (possibly non-existent) file/folder. * Written by: Jesse Jones * * Copyright © 1998-1999 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * * Revision 1.6 2003/08/15 10:05:15 meeroh * Macro changes: * MAC -> TARGET_OS_MAC * WIN -> TARGET_OS_WIN32 * TARGET_CARBON -> TARGET_API_MAC_CARBON * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN * CODE_WARRIOR -> TARGET_CC_METROWERKS * __MWERKS__ -> TARGET_CC_METROWERKS * MSVC -> TARGET_CC_MICROSOFT * _MSC_VER -> TARGET_CC_MICROSOFT * #pragma mark ~ -> #pragma mark - * Added #ifdef PRAGMA_MARK * * Revision 1.5 2003/08/14 06:01:31 meeroh * Replaced FSSpecs with CFURLs/FSRefs * * Revision 1.4 2001/03/05 05:41:34 jesjones * Removed the dollar signs around the Log comment. * * Revision 1.3 2000/12/10 08:52:30 jesjones * Converted header comments to Doxygen format. * * Revision 1.2 2000/11/09 12:35:57 jesjones * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. */ #pragma once #if TARGET_OS_MAC #include <Aliases.h> #include <Files.h> #include <Resources.h> #endif #include <XTypes.h> namespace Whisper { #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED #pragma export on #endif //----------------------------------- // Forward References // class XFolderSpec; class XInStream; class XOutStream; // =================================================================================== // class XFileSystemSpec //! An object that points to a (possibly non-existent) file/folder. // =================================================================================== class FILES_EXPORT XFileSystemSpec { //----------------------------------- // Initialization/Destruction // public: virtual ~XFileSystemSpec(); XFileSystemSpec(); /**< Points to a bogus file. */ XFileSystemSpec(const OSFSSpec& spec); XFileSystemSpec(const XFolderSpec& folder, const std::wstring& fileName); #if TARGET_OS_MAC XFileSystemSpec(int16 volume, int32 parID, const std::wstring& fileName); XFileSystemSpec(const FSSpec& spec); XFileSystemSpec(const FSRef& ref); XFileSystemSpec(AliasHandle alias); explicit XFileSystemSpec(ResID aliasID); explicit XFileSystemSpec(const std::wstring& path); #endif //----------------------------------- // API // public: //! @name Conversion Operators //@{ // OSFSSpec& GetOSSpec() {return mSpec;} const OSFSSpec& GetOSSpec() const {return mSpec;} //@} //! @name Comparisons //@{ bool operator==(const XFileSystemSpec& rhs) const; bool operator!=(const XFileSystemSpec& rhs) const {return !this->operator==(rhs);} //@} //! @name Information //@{ std::wstring GetName() const; /**< Returns the name of the file/folder. */ std::wstring GetPrefix() const; /**< Returns the name sans extension. */ std::wstring GetExtension() const; /**< Returns the text after the last period (may be empty). Note that extensions are always returned as lower case. */ XFolderSpec GetParent() const; bool Exists () const; /**< Returnes true if this represents an existent file or folder */ OSVolume GetVolume() const; std::wstring GetPath() const; #if TARGET_OS_MAC MCFURL GetCFURL() const {return MCFURL(*mSpec, false);} const FSRef& GetFSRef() const; /**< Returns the FSRef if this represenents an existent file or folder */ FSSpec GetFSSpec() const; /**< Returns the FSSpec if this represenents an existent file or folder */ void GetCatalogInfo( FSCatalogInfoBitmap whichInfo, FSCatalogInfo* catalogInfo, HFSUniStr255* outName, FSSpec* fsSpec, FSRef* parentRef) const; /**< Gets catalog info if this represenents an existent file or folder, throws otherwise */ OSErr GetCatalogInfoErr( FSCatalogInfoBitmap whichInfo, FSCatalogInfo* catalogInfo, HFSUniStr255* outName, FSSpec* fsSpec, FSRef* parentRef) const; /**< Gets catalog info if this represenents an existent file or folder, returns error otherwise */ void SetCatalogInfo( FSCatalogInfoBitmap whichInfo, FSCatalogInfo* catalogInfo) const; /**< Sets catalog info if this represenents an existent file or folder, throws otherwise */ #endif //@} //! @name Streaming //@{ friend XInStream& operator>>(XInStream& stream, XFileSystemSpec& value); friend XOutStream& operator<<(XOutStream& stream, const XFileSystemSpec& value); //@} //----------------------------------- // Member Data // protected: #if TARGET_OS_MAC // On Mac OS, we can have the file spec, or the file ref, or both // Since converting from one to the other could be expensive, we create // them lazily. Calling GetOSSpec or GetFSRef may cause us to update // one or the other mutable OSFSSpec mSpec; // We cache the FSRef because it's expensive to convert // a CFURL to an FSRef mutable FSRef mFSRef; mutable bool mHaveFSRef; void InitWithOSFSSpec (const OSFSSpec& inSpec); void InitWithFSRef (const FSRef& inFSRef); void UpdateFSRef () const; void ClearFSRef () const; #endif #if TARGET_OS_WIN32 OSFSSpec mSpec; mutable std::wstring mLongName; #endif }; // =================================================================================== // Exception helpers // // =================================================================================== #if TARGET_OS_MAC //--------------------------------------------------------------- // ThrowFileErr // FILES_EXPORT void ThrowFileErr(const XFileSystemSpec& spec, OSStatus err); //--------------------------------------------------------------- // ThrowIfFileErr // inline void ThrowIfFileErr(const XFileSystemSpec& spec, OSStatus err) { if (err != noErr) ThrowFileErr(spec, err); } #endif #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED #pragma export reset #endif } // namespace Whisper \ No newline at end of file Index: XMemoryMappedFile.h =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/XMemoryMappedFile.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** XMemoryMappedFile.h 15 Aug 2003 10:08:06 -0000 1.8 --- XMemoryMappedFile.h 28 Mar 2004 22:13:16 -0000 1.9 *************** *** 1,174 **** ! /* ! * File: XMemoryMappedFile.h ! * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. ! * Written by: Jesse Jones ! * ! * Copyright © 1999-2001 Jesse Jones. ! * This code is distributed under the zlib/libpng license (see License.txt for details). ! * ! * Change History (most recent first): ! * ! * $Log$ ! * Revision 1.8 2003/08/15 10:08:06 meeroh ! * Macro changes: ! * MAC -> TARGET_OS_MAC ! * WIN -> TARGET_OS_WIN32 ! * TARGET_CARBON -> TARGET_API_MAC_CARBON ! * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN ! * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN ! * CODE_WARRIOR -> TARGET_CC_METROWERKS ! * __MWERKS__ -> TARGET_CC_METROWERKS ! * MSVC -> TARGET_CC_MICROSOFT ! * _MSC_VER -> TARGET_CC_MICROSOFT ! * #pragma mark ~ -> #pragma mark - ! * Added #ifdef PRAGMA_MARK ! * ! * Revision 1.7 2003/08/14 06:01:58 meeroh ! * Replaced FSSpecs with CFURLs/FSRefs ! * ! * Revision 1.6 2003/03/16 02:46:08 psnively ! * Updates for CW Pro 8.3 and new zlib/libpng ! * ! * Revision 1.5 2001/04/17 01:44:26 jesjones ! * Got rid of XInvariantMixin. ! * ! * Revision 1.4 2001/03/05 05:42:39 jesjones ! * Removed the dollar signs around the Log comment. ! * ! * Revision 1.3 2000/12/10 08:54:04 jesjones ! * Converted header comments to Doxygen format. ! * ! * Revision 1.2 2000/11/09 12:42:38 jesjones ! * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. ! */ ! ! #pragma once ! ! #include <XFile.h> ! #include <XLockable.h> ! ! namespace Whisper { ! ! #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED ! #pragma export on ! #endif ! ! ! // =================================================================================== ! // class XMemoryMappedFile ! //! A class that allows a file to be efficiently treated as a bag'o'bits. ! // =================================================================================== ! class FILES_EXPORT XMemoryMappedFile : public XLockableMixin { ! ! //----------------------------------- ! // Initialization/Destruction ! // ! public: ! virtual ~XMemoryMappedFile(); ! /**< ASSERTs if the file is still open (however it will close ! the file if it's open to make it easier to write exception ! safe code). */ ! ! explicit XMemoryMappedFile(const XFileSpec& file); ! ! XMemoryMappedFile(const XFolderSpec& folder, const std::wstring& fileName); ! ! private: ! XMemoryMappedFile(const XMemoryMappedFile& rhs); ! ! XMemoryMappedFile& operator=(const XMemoryMappedFile& rhs); ! ! //----------------------------------- ! // New API ! // ! public: ! //! @name Open/Close ! //@{ ! void Open(EFilePermission perm, uint32 maxBytes = 0); ! /**< File should already exist. maxBytes is used with writeable files. If it's ! zero the file cannot be expanded. It can be set to an arbitrarily large ! value for growable files, but if enough memory (Mac) or swap file space ! (Win) cannot be found an exception will be thrown. */ ! ! void Open(OSType creator, OSType fileType, EFilePermission perm, uint32 maxBytes = 0); ! /**< Creates the file if it doesn't already exist. ! Perm can be kReadPermission, kWritePermission, or kReadWritePermission. ! creator and fileType are ignored on Windows. */ ! ! void Close(); ! void Close(uint32 newSize); ! /**< May throw an exception. For growable files you may specify the final file size. */ ! ! bool IsOpened() const; ! //@} ! ! //! @name Read/Write ! //@{ ! uint8* GetBuffer(); ! const uint8* GetBuffer() const {return const_cast<XMemoryMappedFile*>(this)->GetBuffer();} ! /**< File must be locked. */ ! ! uint32 GetBufferSize() const; ! /**< Returns the size in bytes of the buffer. The file must be open. */ ! ! void Flush(); ! //@} ! ! //! @name Misc ! //@{ ! XFileSpec GetSpec() const {return mFile.GetSpec();} ! ! #if TARGET_OS_MAC ! void EnablePurging(bool enable = true); ! /**< On the Mac the buffer is allocated in temp memory when possible. ! In order to work well with other app's the handle defaults to ! purgeable (for read-only files), but you can disable purging with ! this method. */ ! #endif ! //@} ! ! //----------------------------------- ! // Inherited API ! // ! protected: ! friend class ZCheckInvariant; ! void Invariant() const; ! ! virtual void OnLock(bool moveHigh); ! ! virtual void OnUnlock(); ! ! //----------------------------------- ! // Internal API ! // ! protected: ! void DoOpen(EFilePermission perm, uint32 flags, uint32 maxBytes); ! ! //----------------------------------- ! // Member Data ! // ! protected: ! XFile mFile; ! bool mWriting; ! uint32 mMaxBytes; ! ! #if TARGET_OS_MAC ! // int16 mRefNum; ! bool mReading; ! Handle mData; // purgable handle allocated in temp memory (or app memory if temp memory is exhausted) ! ! bool mPurgable; ! ! #elif TARGET_OS_WIN32 ! HANDLE mFileHandle; ! HANDLE mMapHandle; ! void* mData; ! #endif ! }; ! ! ! #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED ! #pragma export reset ! #endif ! ! } // namespace Whisper --- 1,4 ---- ! /* * File: XMemoryMappedFile.h * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * $Log$ ! /* * File: XMemoryMappedFile.h * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Revision 1.9 2004/03/28 22:13:16 psnively ! /* * File: XMemoryMappedFile.h * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. ! /* * File: XMemoryMappedFile.h * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * * Revision 1.8 2003/08/15 10:08:06 meeroh * Macro changes: * MAC -> TARGET_OS_MAC * WIN -> TARGET_OS_WIN32 * TARGET_CARBON -> TARGET_API_MAC_CARBON * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN * CODE_WARRIOR -> TARGET_CC_METROWERKS * __MWERKS__ -> TARGET_CC_METROWERKS * MSVC -> TARGET_CC_MICROSOFT * _MSC_VER -> TARGET_CC_MICROSOFT * #pragma mark ~ -> #pragma mark - * Added #ifdef PRAGMA_MARK * * Revision 1.7 2003/08/14 06:01:58 meeroh * Replaced FSSpecs with CFURLs/FSRefs * * Revision 1.6 2003/03/16 02:46:08 psnively * Updates for CW Pro 8.3 and new zlib/libpng * * Revision 1.5 2001/04/17 01:44:26 jesjones * Got rid of XInvariantMixin. * * Revision 1.4 2001/03/05 05:42:39 jesjones * Removed the dollar signs around the Log comment. * * Revision 1.3 2000/12/10 08:54:04 jesjones * Converted header comments to Doxygen format. * * Revision 1.2 2000/11/09 12:42:38 jesjones * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. */ #pragma once #include <XFile.h> #include <XLockable.h> namespace Whisper { #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED #pragma export on #endif // =================================================================================== // class XMemoryMappedFile //! A class that allows a file to be efficiently treated as a bag'o'bits. // =================================================================================== class FILES_EXPORT XMemoryMappedFile : public XLockableMixin { //----------------------------------- // Initialization/Destruction // public: virtual ~XMemoryMappedFile(); /**< ASSERTs if the file is still open (however it will close the file if it's open to make it easier to write exception safe code). */ explicit XMemoryMappedFile(const XFileSpec& file); XMemoryMappedFile(const XFolderSpec& folder, const std::wstring& fileName); private: XMemoryMappedFile(const XMemoryMappedFile& rhs); XMemoryMappedFile& operator=(const XMemoryMappedFile& rhs); //----------------------------------- // New API // public: //! @name Open/Close //@{ void Open(EFilePermission perm, uint32 maxBytes = 0); /**< File should already exist. maxBytes is used with writeable files. If it's zero the file cannot be expanded. It can be set to an arbitrarily large value for growable files, but if enough memory (Mac) or swap file space (Win) cannot be found an exception will be thrown. */ void Open(OSType creator, OSType fileType, EFilePermission perm, uint32 maxBytes = 0); /**< Creates the file if it doesn't already exist. Perm can be kReadPermission, kWritePermission, or kReadWritePermission. creator and fileType are ignored on Windows. */ void Close(); void Close(uint32 newSize); /**< May throw an exception. For growable files you may specify the final file size. */ bool IsOpened() const; //@} //! @name Read/Write //@{ uint8* GetBuffer(); const uint8* GetBuffer() const {return const_cast<XMemoryMappedFile*>(this)->GetBuffer();} /**< File must be locked. */ uint32 GetBufferSize() const; /**< Returns the size in bytes of the buffer. The file must be open. */ void Flush(); //@} //! @name Misc //@{ XFileSpec GetSpec() const {return mFile.GetSpec();} #if TARGET_OS_MAC void EnablePurging(bool enable = true); /**< On the Mac the buffer is allocated in temp memory when possible. In order to work well with other app's the handle defaults to purgeable (for read-only files), but you can disable purging with this method. */ #endif //@} //----------------------------------- // Inherited API // protected: friend class ZCheckInvariant; void Invariant() const; virtual void OnLock(bool moveHigh); virtual void OnUnlock(); //----------------------------------- // Internal API // protected: void DoOpen(EFilePermission perm, uint32 flags, uint32 maxBytes); //----------------------------------- // Member Data // protected: XFile mFile; bool mWriting; uint32 mMaxBytes; #if TARGET_OS_MAC // int16 mRefNum; bool mReading; Handle mData; // purgable handle allocated in temp memory (or app memory if temp memory is exhausted) bool mPurgable; #elif TARGET_OS_WIN32 HANDLE mFileHandle; HANDLE mMapHandle; void* mData; #endif }; #if MULTI_FRAGMENT_APP && PRAGMA_EXPORT_SUPPORTED #pragma export reset #endif } // namespace Whisper \ No newline at end of file |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:13
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Files/Source/Files/Mac Modified Files: MMemoryMappedFile.cpp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: MMemoryMappedFile.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac/MMemoryMappedFile.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MMemoryMappedFile.cpp 15 Aug 2003 09:53:49 -0000 1.7 --- MMemoryMappedFile.cpp 28 Mar 2004 22:13:16 -0000 1.8 *************** *** 1,547 **** ! /* ! * File: MMemoryMappedFile.cpp ! * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. ! * Written by: Jesse Jones ! * ! * Copyright © 1999-2001 Jesse Jones. ! * This code is distributed under the zlib/libpng license (see License.txt for details). ! * ! * Change History (most recent first): ! * ! * $Log$ ! * Revision 1.7 2003/08/15 09:53:49 meeroh ! * Macro changes: ! * MAC -> TARGET_OS_MAC ! * WIN -> TARGET_OS_WIN32 ! * TARGET_CARBON -> TARGET_API_MAC_CARBON ! * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN ! * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN ! * CODE_WARRIOR -> TARGET_CC_METROWERKS ! * __MWERKS__ -> TARGET_CC_METROWERKS ! * MSVC -> TARGET_CC_MICROSOFT ! * _MSC_VER -> TARGET_CC_MICROSOFT ! * #pragma mark ~ -> #pragma mark - ! * Added #ifdef PRAGMA_MARK ! * ! * Revision 1.6 2003/08/14 06:00:21 meeroh ! * Replaced FSSpecs with CFURLs/FSRefs ! * ! * Revision 1.5 2001/04/21 03:26:52 jesjones ! * Updated for the new debug macros. ! * ! * Revision 1.4 2001/04/17 01:41:09 jesjones ! * Got rid of XInvariantMixin. ! * ! * Revision 1.3 2000/12/10 04:04:14 jesjones ! * Replaced int16_cast, uint32_cast, etc with numeric_cast. ! * ! * Revision 1.2 2000/11/09 09:15:45 jesjones ! * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. ! */ ! ! #include <XWhisperHeader.h> ! #include <XMemoryMappedFile.h> ! ! #include <XError.h> ! #include <XExceptions.h> ! #include <XIntConversions.h> ! #include <XLocker.h> ! #include <XNumbers.h> ! #include <XStringUtils.h> ! ! namespace Whisper { ! ! ! //----------------------------------- ! // Constants ! // ! #if DEBUG ! const uint32 kTail = 'Tail'; ! const uint32 kTailSize = sizeof(kTail); ! #else ! const uint32 kTailSize = 0; ! #endif ! ! ! // =================================================================================== ! // Internal Functions ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ! // ThrowFileErr ! // ! //--------------------------------------------------------------- ! static void ThrowFileErr(const XFileSpec& spec, OSStatus err) ! { ! switch (err) { ! case dirFulErr: ! case dskFulErr: ! case nsvErr: ! case ioErr: ! case fnOpnErr: ! case eofErr: ! case posErr: ! case mFulErr: ! case tmfoErr: ! case fnfErr: ! case wPrErr: ! case fLckdErr: ! ! case vLckdErr: ! case fBsyErr: ! case dupFNErr: ! case opWrErr: ! case rfNumErr: ! case gfpErr: ! case volOffLinErr: ! case permErr: ! case volOnLinErr: ! case nsDrvErr: ! case noMacDskErr: ! case wrPermErr: ! case dirNFErr: ! case tmwdoErr: ! case volGoneErr: ! { ! #if DEBUG ! std::wstring mesg = XError::Instance()->GetText(err) + L" with file " + spec.GetName(); ! #else ! std::wstring mesg = LoadWhisperString(L"File error ##1 (with file '#2')", Int32ToStr(err), spec.GetName()); ! #endif ! throw std::runtime_error(ToUTF8Str(mesg)); ! } ! break; ! ! default: ! ThrowErr(err); ! } ! } ! ! ! //--------------------------------------------------------------- ! // ! // ThrowIfFileErr ! // ! //--------------------------------------------------------------- ! inline void ThrowIfFileErr(const XFileSpec& spec, OSStatus err) ! { ! if (err != noErr) ! ThrowFileErr(spec, err); ! } ! ! #pragma mark - ! ! // =================================================================================== ! // class XMemoryMappedFile ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::~XMemoryMappedFile ! // ! //--------------------------------------------------------------- ! XMemoryMappedFile::~XMemoryMappedFile() ! { ! PRECONDITION(!this->IsOpened()); // in the normal course of events you should explicitly close the file ! CALL_INVARIANT; ! ! if (this->IsOpened()) { // but if an exception was thrown the file may still be open ! try { ! if (mWriting && mData != nil) ! this->Flush(); ! ! mFile.Close(); // if so, we need to close the file (and attempt to save any changes) ! ! } catch (...) { ! // can't throw from dtor ! } ! } ! ! if (mData != nil) ! DisposeHandle(mData); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::XMemoryMappedFile (XFileSpec) ! // ! //--------------------------------------------------------------- ! XMemoryMappedFile::XMemoryMappedFile(const XFileSpec& file) : mFile(file) ! { ! // mRefNum = kNoFileRefNum; ! ! mReading = false; ! mWriting = false; ! ! mData = nil; ! mMaxBytes = 0; ! mPurgable = true; ! ! CALL_INVARIANT; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::XMemoryMappedFile (XFolderSpec, wstring) ! // ! //--------------------------------------------------------------- ! XMemoryMappedFile::XMemoryMappedFile(const XFolderSpec& folder, const std::wstring& name) : mFile(folder, name) ! { ! // mRefNum = kNoFileRefNum; ! ! mReading = false; ! mWriting = false; ! ! mData = nil; ! mMaxBytes = 0; ! mPurgable = true; ! ! CALL_INVARIANT; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::Open (EFilePermission, uint32) ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::Open(EFilePermission perm, uint32 maxBytes) ! { ! PRECONDITION(!this->IsOpened()); ! PRECONDITION(mData == nil); ! CHECK_INVARIANT; ! ! int16 tempRef = kNoFileRefNum; ! mMaxBytes = maxBytes; ! ! // Open the file ! mFile.Open(perm); ! // OSErr err = ::FSOpenFork(&mSpec.GetFSRef(), 0, nil, perm, &tempRef); ! // ThrowIfFileErr(mSpec, err); ! ! // Initialize maxBytes if the user hasn't specified a value ! if (mMaxBytes == 0) { ! // int64 bytes; ! // err = ::FSGetForkSize(tempRef, &bytes); ! // ThrowIfFileErr(mSpec, err); ! ! // mMaxBytes = numeric_cast<uint32>(bytes); ! mMaxBytes = mFile.GetLength(); ! } ! ! // Set some member variables ! // mRefNum = tempRef; ! mReading = perm == kReadPermission || perm == kReadWritePermission; ! mWriting = perm == kWritePermission || perm == kReadWritePermission; ! ! POSTCONDITION(this->IsOpened()); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::Open (OSType, OSType, EFilePermission, uint32) ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::Open(OSType creator, OSType fileType, EFilePermission perm, uint32 maxBytes) ! { ! PRECONDITION(!this->IsOpened()); ! PRECONDITION(mData == nil); ! CHECK_INVARIANT; ! ! int16 tempRef = kNoFileRefNum; ! mMaxBytes = maxBytes; ! ! // Open the file ! mFile.Open(creator, fileType, perm); ! ! // Initialize maxBytes if the user hasn't specified a value ! if (mMaxBytes == 0) { ! // int64 bytes; ! // err = ::FSGetForkSize(tempRef, &bytes); ! // ThrowIfFileErr(mSpec, err); ! ! // mMaxBytes = numeric_cast<uint32>(bytes); ! mMaxBytes = mFile.GetLength(); ! } ! ! // Set some member variables ! // mRefNum = tempRef; ! mReading = perm == kReadPermission || perm == kReadWritePermission; ! mWriting = perm == kWritePermission || perm == kReadWritePermission; ! ! POSTCONDITION(this->IsOpened()); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::Close () ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::Close() ! { ! PRECONDITION(this->IsOpened()); ! CHECK_INVARIANT; ! ! try { ! if (mWriting && mData != nil) ! this->Flush(); ! ! mFile.Close(); // File Manager buffers data and flushes on close so an error is quite possible ! // OSErr err = FSClose(mRefNum); ! // ThrowIfFileErr(mSpec, err); // File Manager buffers data and flushes on close so an error is quite possible ! ! if (mData != nil) { ! DisposeHandle(mData); ! mData = nil; ! } ! ! // mRefNum = kNoFileRefNum; ! mReading = false; ! mWriting = false; ! ! } catch (...) { ! if (mData != nil) { ! DisposeHandle(mData); ! mData = nil; ! } ! ! // mRefNum = kNoFileRefNum; ! ! throw; ! } ! ! POSTCONDITION(!this->IsOpened()); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::Close (uint32) ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::Close(uint32 newSize) ! { ! PRECONDITION(mWriting); ! CHECK_INVARIANT; ! ! if (mData != nil && newSize != mMaxBytes) { // mData will only be nil if the file was never locked ! ASSERT(*mData != nil); ! ASSERT(newSize <= GetHandleSize(mData) - kTailSize); ! ! SetHandleSize(mData, newSize + kTailSize); ! ThrowIfMemError(); ! ! mMaxBytes = newSize; ! ! #if DEBUG ! uint32* tail = reinterpret_cast<uint32*>(*mData + mMaxBytes); ! *tail = kTail; ! #endif ! } ! ! this->Close(); ! ! POSTCONDITION(!this->IsOpened()); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::IsOpened ! // ! //--------------------------------------------------------------- ! bool XMemoryMappedFile::IsOpened() const ! { ! return mFile.IsOpened(); ! // bool open = mRefNum != kNoFileRefNum; ! ! // return open; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::GetBuffer ! // ! //--------------------------------------------------------------- ! uint8* XMemoryMappedFile::GetBuffer() ! { ! PRECONDITION(this->IsLocked()); ! PRECONDITION(mData != nil); ! PRECONDITION(*mData != nil); ! ! return (uint8*) *mData; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::GetBufferSize ! // ! //--------------------------------------------------------------- ! uint32 XMemoryMappedFile::GetBufferSize() const ! { ! PRECONDITION(this->IsOpened()); // mMaxBytes is set via Open ! ! return mMaxBytes; ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::Flush ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::Flush() ! { ! PRECONDITION(mWriting); ! PRECONDITION(this->IsOpened()); ! CHECK_INVARIANT; ! ! if (mData != nil) { // will only be nil if the file hasn't been locked yet ! ASSERT(*mData != nil); // writable files aren't purgeable ! ! mFile.Seek(kSeekFromStart, 0); ! // OSErr err = SetFPos(mRefNum, fsFromStart, 0); ! // ThrowIfFileErr(mSpec, err); ! ! uint32 bytes = GetHandleSize(mData) - kTailSize; ! ! { ! XLocker lock(this); ! mFile.Write(*mData,bytes); ! // err = FSWrite(mRefNum, &bytes, *mData); ! // ThrowIfFileErr(mSpec, err); ! } ! ! mFile.Trim(); ! // err = SetEOF(mRefNum, bytes); ! // ThrowIfFileErr(mSpec, err); ! } ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::EnablePurging ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::EnablePurging(bool enable) ! { ! ASSERT_IF(enable, !mWriting); ! CHECK_INVARIANT; ! ! if (enable != mPurgable) { ! mPurgable = enable; ! ! if (mData != nil && *mData != nil) { ! if (mPurgable) ! HPurge(mData); // this will have no effect while the handle is locked ! else ! HNoPurge(mData); ! ThrowIfMemError(); ! } ! } ! ! POSTCONDITION(true); ! } ! ! #if PRAGMA_MARK ! #pragma mark Ê ! #endif ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::Invariant ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::Invariant() const ! { ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::OnLock ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::OnLock(bool moveHigh) ! { ! PRECONDITION(this->IsOpened()); ! ! bool dirty = false; ! OSErr err = noErr; ! ! // Allocate (or re-allocate) the handle ! if (mData == nil) { ! mData = TempNewHandle(numeric_cast<int32>(mMaxBytes + kTailSize), &err); ! if (mData == nil) ! mData = NewHandle(mMaxBytes + kTailSize); ! ThrowIfMemFail(mData); ! ! dirty = true; ! ! } else if (*mData == nil) { ! ReallocateHandle(mData, numeric_cast<int32>(mMaxBytes + kTailSize)); ! ThrowIfMemError(); ! ! HNoPurge(mData); ! ThrowIfMemError(); ! ! dirty = true; ! } ! ! // Lock it ! if (moveHigh) ! HLockHi(mData); ! else ! HLock(mData); ! ThrowIfMemError(); ! ! // And read in the file as necessary ! if (dirty && mReading) { ! #if DEBUG ! uint32* tail = reinterpret_cast<uint32*>(*mData + mMaxBytes); ! *tail = kTail; ! #endif ! ! uint32 bytes = mFile.GetLength(); ! ! bytes = Min(bytes, mMaxBytes); ! ! mFile.Read(*mData, bytes); ! } ! } ! ! ! //--------------------------------------------------------------- ! // ! // XMemoryMappedFile::OnUnlock ! // ! //--------------------------------------------------------------- ! void XMemoryMappedFile::OnUnlock() ! { ! PRECONDITION(mData != nil); ! PRECONDITION(*mData != nil); ! ! #if DEBUG ! uint32* tail = reinterpret_cast<uint32*>(*mData + mMaxBytes); ! ASSERT(*tail == kTail); ! #endif ! ! HUnlock(mData); ! ThrowIfMemError(); ! ! if (mReading && !mWriting && mPurgable) { ! HPurge(mData); ! ThrowIfMemError(); ! } ! } ! ! ! } // namespace Whisper --- 1,4 ---- ! /* * File: MMemoryMappedFile.cpp * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * $Log$ ! /* * File: MMemoryMappedFile.cpp * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Revision 1.8 2004/03/28 22:13:16 psnively ! /* * File: MMemoryMappedFile.cpp * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. ! /* * File: MMemoryMappedFile.cpp * Summary: A class that allows a file to be efficiently treated as a bag'o'bits. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * * Revision 1.7 2003/08/15 09:53:49 meeroh * Macro changes: * MAC -> TARGET_OS_MAC * WIN -> TARGET_OS_WIN32 * TARGET_CARBON -> TARGET_API_MAC_CARBON * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN * CODE_WARRIOR -> TARGET_CC_METROWERKS * __MWERKS__ -> TARGET_CC_METROWERKS * MSVC -> TARGET_CC_MICROSOFT * _MSC_VER -> TARGET_CC_MICROSOFT * #pragma mark ~ -> #pragma mark - * Added #ifdef PRAGMA_MARK * * Revision 1.6 2003/08/14 06:00:21 meeroh * Replaced FSSpecs with CFURLs/FSRefs * * Revision 1.5 2001/04/21 03:26:52 jesjones * Updated for the new debug macros. * * Revision 1.4 2001/04/17 01:41:09 jesjones * Got rid of XInvariantMixin. * * Revision 1.3 2000/12/10 04:04:14 jesjones * Replaced int16_cast, uint32_cast, etc with numeric_cast. * * Revision 1.2 2000/11/09 09:15:45 jesjones * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. */ #include <XWhisperHeader.h> #include <XMemoryMappedFile.h> #include <XError.h> #include <XExceptions.h> #include <XIntConversions.h> #include <XLocker.h> #include <XNumbers.h> #include <XStringUtils.h> namespace Whisper { //----------------------------------- // Constants // #if DEBUG const uint32 kTail = 'Tail'; const uint32 kTailSize = sizeof(kTail); #else const uint32 kTailSize = 0; #endif // =================================================================================== // Internal Functions // =================================================================================== //--------------------------------------------------------------- // // ThrowFileErr // //--------------------------------------------------------------- static void ThrowFileErr(const XFileSpec& spec, OSStatus err) { switch (err) { case dirFulErr: case dskFulErr: case nsvErr: case ioErr: case fnOpnErr: case eofErr: case posErr: case mFulErr: case tmfoErr: case fnfErr: case wPrErr: case fLckdErr: case vLckdErr: case fBsyErr: case dupFNErr: case opWrErr: case rfNumErr: case gfpErr: case volOffLinErr: case permErr: case volOnLinErr: case nsDrvErr: case noMacDskErr: case wrPermErr: case dirNFErr: case tmwdoErr: case volGoneErr: { #if DEBUG std::wstring mesg = XError::Instance()->GetText(err) + L" with file " + spec.GetName(); #else std::wstring mesg = LoadWhisperString(L"File error ##1 (with file '#2')", Int32ToStr(err), spec.GetName()); #endif throw std::runtime_error(ToUTF8Str(mesg)); } break; default: ThrowErr(err); } } //--------------------------------------------------------------- // // ThrowIfFileErr // //--------------------------------------------------------------- inline void ThrowIfFileErr(const XFileSpec& spec, OSStatus err) { if (err != noErr) ThrowFileErr(spec, err); } #pragma mark - // =================================================================================== // class XMemoryMappedFile // =================================================================================== //--------------------------------------------------------------- // // XMemoryMappedFile::~XMemoryMappedFile // //--------------------------------------------------------------- XMemoryMappedFile::~XMemoryMappedFile() { PRECONDITION(!this->IsOpened()); // in the normal course of events you should explicitly close the file CALL_INVARIANT; if (this->IsOpened()) { // but if an exception was thrown the file may still be open try { if (mWriting && mData != nil) this->Flush(); mFile.Close(); // if so, we need to close the file (and attempt to save any changes) } catch (...) { // can't throw from dtor } } if (mData != nil) DisposeHandle(mData); } //--------------------------------------------------------------- // // XMemoryMappedFile::XMemoryMappedFile (XFileSpec) // //--------------------------------------------------------------- XMemoryMappedFile::XMemoryMappedFile(const XFileSpec& file) : mFile(file) { // mRefNum = kNoFileRefNum; mReading = false; mWriting = false; mData = nil; mMaxBytes = 0; mPurgable = true; CALL_INVARIANT; } //--------------------------------------------------------------- // // XMemoryMappedFile::XMemoryMappedFile (XFolderSpec, wstring) // //--------------------------------------------------------------- XMemoryMappedFile::XMemoryMappedFile(const XFolderSpec& folder, const std::wstring& name) : mFile(folder, name) { // mRefNum = kNoFileRefNum; mReading = false; mWriting = false; mData = nil; mMaxBytes = 0; mPurgable = true; CALL_INVARIANT; } //--------------------------------------------------------------- // // XMemoryMappedFile::Open (EFilePermission, uint32) // //--------------------------------------------------------------- void XMemoryMappedFile::Open(EFilePermission perm, uint32 maxBytes) { PRECONDITION(!this->IsOpened()); PRECONDITION(mData == nil); CHECK_INVARIANT; int16 tempRef = kNoFileRefNum; mMaxBytes = maxBytes; // Open the file mFile.Open(perm); // OSErr err = ::FSOpenFork(&mFile.GetFSRef(), 0, nil, perm, &tempRef); // ThrowIfFileErr(mFile, err); // Initialize maxBytes if the user hasn't specified a value if (mMaxBytes == 0) { // int64 bytes; // err = ::FSGetForkSize(tempRef, &bytes); // ThrowIfFileErr(mFile, err); // mMaxBytes = numeric_cast<uint32>(bytes); mMaxBytes = mFile.GetLength(); } // Set some member variables // mRefNum = tempRef; mReading = perm == kReadPermission || perm == kReadWritePermission; mWriting = perm == kWritePermission || perm == kReadWritePermission; POSTCONDITION(this->IsOpened()); } //--------------------------------------------------------------- // // XMemoryMappedFile::Open (OSType, OSType, EFilePermission, uint32) // //--------------------------------------------------------------- void XMemoryMappedFile::Open(OSType creator, OSType fileType, EFilePermission perm, uint32 maxBytes) { PRECONDITION(!this->IsOpened()); PRECONDITION(mData == nil); CHECK_INVARIANT; int16 tempRef = kNoFileRefNum; mMaxBytes = maxBytes; // Open the file mFile.Open(creator, fileType, perm); // Initialize maxBytes if the user hasn't specified a value if (mMaxBytes == 0) { // int64 bytes; // err = ::FSGetForkSize(tempRef, &bytes); // ThrowIfFileErr(mFile, err); // mMaxBytes = numeric_cast<uint32>(bytes); mMaxBytes = mFile.GetLength(); } // Set some member variables // mRefNum = tempRef; mReading = perm == kReadPermission || perm == kReadWritePermission; mWriting = perm == kWritePermission || perm == kReadWritePermission; POSTCONDITION(this->IsOpened()); } //--------------------------------------------------------------- // // XMemoryMappedFile::Close () // //--------------------------------------------------------------- void XMemoryMappedFile::Close() { PRECONDITION(this->IsOpened()); CHECK_INVARIANT; try { if (mWriting && mData != nil) this->Flush(); mFile.Close(); // File Manager buffers data and flushes on close so an error is quite possible // OSErr err = FSClose(mRefNum); // ThrowIfFileErr(mFile, err); // File Manager buffers data and flushes on close so an error is quite possible if (mData != nil) { DisposeHandle(mData); mData = nil; } // mRefNum = kNoFileRefNum; mReading = false; mWriting = false; } catch (...) { if (mData != nil) { DisposeHandle(mData); mData = nil; } // mRefNum = kNoFileRefNum; throw; } POSTCONDITION(!this->IsOpened()); } //--------------------------------------------------------------- // // XMemoryMappedFile::Close (uint32) // //--------------------------------------------------------------- void XMemoryMappedFile::Close(uint32 newSize) { PRECONDITION(mWriting); CHECK_INVARIANT; if (mData != nil && newSize != mMaxBytes) { // mData will only be nil if the file was never locked ASSERT(*mData != nil); ASSERT(newSize <= GetHandleSize(mData) - kTailSize); SetHandleSize(mData, newSize + kTailSize); ThrowIfMemError(); mMaxBytes = newSize; #if DEBUG uint32* tail = reinterpret_cast<uint32*>(*mData + mMaxBytes); *tail = kTail; #endif } this->Close(); POSTCONDITION(!this->IsOpened()); } //--------------------------------------------------------------- // // XMemoryMappedFile::IsOpened // //--------------------------------------------------------------- bool XMemoryMappedFile::IsOpened() const { return mFile.IsOpened(); // bool open = mRefNum != kNoFileRefNum; // return open; } //--------------------------------------------------------------- // // XMemoryMappedFile::GetBuffer // //--------------------------------------------------------------- uint8* XMemoryMappedFile::GetBuffer() { PRECONDITION(this->IsLocked()); PRECONDITION(mData != nil); PRECONDITION(*mData != nil); return (uint8*) *mData; } //--------------------------------------------------------------- // // XMemoryMappedFile::GetBufferSize // //--------------------------------------------------------------- uint32 XMemoryMappedFile::GetBufferSize() const { PRECONDITION(this->IsOpened()); // mMaxBytes is set via Open return mMaxBytes; } //--------------------------------------------------------------- // // XMemoryMappedFile::Flush // //--------------------------------------------------------------- void XMemoryMappedFile::Flush() { PRECONDITION(mWriting); PRECONDITION(this->IsOpened()); CHECK_INVARIANT; if (mData != nil) { // will only be nil if the file hasn't been locked yet ASSERT(*mData != nil); // writable files aren't purgeable mFile.Seek(kSeekFromStart, 0); // OSErr err = SetFPos(mRefNum, fsFromStart, 0); // ThrowIfFileErr(mFile, err); uint32 bytes = GetHandleSize(mData) - kTailSize; { XLocker lock(this); mFile.Write(*mData,bytes); // err = FSWrite(mRefNum, &bytes, *mData); // ThrowIfFileErr(mFile, err); } mFile.Trim(); // err = SetEOF(mRefNum, bytes); // ThrowIfFileErr(mFile, err); } } //--------------------------------------------------------------- // // XMemoryMappedFile::EnablePurging // //--------------------------------------------------------------- void XMemoryMappedFile::EnablePurging(bool enable) { ASSERT_IF(enable, !mWriting); CHECK_INVARIANT; if (enable != mPurgable) { mPurgable = enable; if (mData != nil && *mData != nil) { if (mPurgable) HPurge(mData); // this will have no effect while the handle is locked else HNoPurge(mData); ThrowIfMemError(); } } POSTCONDITION(true); } #if PRAGMA_MARK #pragma mark Ê #endif //--------------------------------------------------------------- // // XMemoryMappedFile::Invariant // //--------------------------------------------------------------- void XMemoryMappedFile::Invariant() const { } //--------------------------------------------------------------- // // XMemoryMappedFile::OnLock // //--------------------------------------------------------------- void XMemoryMappedFile::OnLock(bool moveHigh) { PRECONDITION(this->IsOpened()); bool dirty = false; OSErr err = noErr; // Allocate (or re-allocate) the handle if (mData == nil) { mData = TempNewHandle(numeric_cast<int32>(mMaxBytes + kTailSize), &err); if (mData == nil) mData = NewHandle(mMaxBytes + kTailSize); ThrowIfMemFail(mData); dirty = true; } else if (*mData == nil) { ReallocateHandle(mData, numeric_cast<int32>(mMaxBytes + kTailSize)); ThrowIfMemError(); HNoPurge(mData); ThrowIfMemError(); dirty = true; } // Lock it if (moveHigh) HLockHi(mData); else HLock(mData); ThrowIfMemError(); // And read in the file as necessary if (dirty && mReading) { #if DEBUG uint32* tail = reinterpret_cast<uint32*>(*mData + mMaxBytes); *tail = kTail; #endif uint32 bytes = mFile.GetLength(); bytes = Min(bytes, mMaxBytes); mFile.Read(*mData, bytes); } } //--------------------------------------------------------------- // // XMemoryMappedFile::OnUnlock // //--------------------------------------------------------------- void XMemoryMappedFile::OnUnlock() { PRECONDITION(mData != nil); PRECONDITION(*mData != nil); #if DEBUG uint32* tail = reinterpret_cast<uint32*>(*mData + mMaxBytes); ASSERT(*tail == kTail); #endif HUnlock(mData); ThrowIfMemError(); if (mReading && !mWriting && mPurgable) { HPurge(mData); ThrowIfMemError(); } } } // namespace Whisper \ No newline at end of file |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:12
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Graphics Modified Files: Graphics.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Graphics.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Graphics/Graphics.mcp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 Binary files /tmp/cvsSq3MGR and /tmp/cvsBbi5uS differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:11
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Tester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Files/Tester Modified Files: FilesTester.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: FilesTester.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Tester/FilesTester.mcp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 Binary files /tmp/cvs5y8QEU and /tmp/cvs0lsmDU differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:11
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Core/Source/Debugging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Core/Source/Debugging Modified Files: XLogFile.cpp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: XLogFile.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Core/Source/Debugging/XLogFile.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XLogFile.cpp 15 Aug 2003 10:07:58 -0000 1.6 --- XLogFile.cpp 28 Mar 2004 22:13:15 -0000 1.7 *************** *** 1,296 **** ! /* ! * File: XLogFile.cpp ! * Summary: Dumps information out to a file in the app's folder. ! * Written by: Jesse Jones ! * ! * Copyright © 1999-2001 Jesse Jones. ! * This code is distributed under the zlib/libpng license (see License.txt for details). ! * ! * Change History (most recent first): ! * ! * $Log$ ! * Revision 1.6 2003/08/15 10:07:58 meeroh ! * Macro changes: ! * MAC -> TARGET_OS_MAC ! * WIN -> TARGET_OS_WIN32 ! * TARGET_CARBON -> TARGET_API_MAC_CARBON ! * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN ! * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN ! * CODE_WARRIOR -> TARGET_CC_METROWERKS ! * __MWERKS__ -> TARGET_CC_METROWERKS ! * MSVC -> TARGET_CC_MICROSOFT ! * _MSC_VER -> TARGET_CC_MICROSOFT ! * #pragma mark ~ -> #pragma mark - ! * Added #ifdef PRAGMA_MARK ! * ! * Revision 1.5 2003/08/14 06:01:50 meeroh ! * Replaced FSSpecs with CFURLs/FSRefs ! * ! * Revision 1.4 2001/04/17 01:44:21 jesjones ! * Got rid of XInvariantMixin. ! * ! * Revision 1.3 2000/12/10 04:10:29 jesjones ! * Replaced int16_cast, uint32_cast, etc with numeric_cast. ! * ! * Revision 1.2 2000/11/09 12:42:28 jesjones ! * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. ! */ ! ! #include <XWhisperHeader.h> ! #include <XLogFile.h> ! #include <XTranscode.h> ! ! #include <cstdarg> ! #include <cstdio> ! ! #include <XNumbers.h> ! ! namespace Whisper { ! ! using namespace std; ! ! ! // =================================================================================== ! // Internal Functions ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ! // FSSpecOpen ! // ! //--------------------------------------------------------------- ! #if TARGET_OS_MAC && TARGET_CC_METROWERKS ! #include <FSp_fopen.h> ! static FILE* FSSpecOpen(const OSFSSpec& spec, const char* mode) ! { ! OSFSSpec baseSpec(::CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, *spec)); ! ! FSRef baseRef; ! if (!::CFURLGetFSRef(*baseSpec, &baseRef)) { ! return nil; ! } ! ! MCoreString path = ::CFURLCopyLastPathComponent(*spec); ! ! HFSUniStr255 hfsPath = ToHFSUniStr(path.c_str()); ! return FSRefParentAndFilename_fopen(&baseRef, &hfsPath, mode); ! } ! #endif ! ! #if PRAGMA_MARK ! #pragma mark - ! #endif ! ! // =================================================================================== ! // class XLogFile ! // =================================================================================== ! ! //--------------------------------------------------------------- ! // ! // XLogFile::~XLogFile ! // ! //--------------------------------------------------------------- ! XLogFile::~XLogFile() ! { ! if (mFile != nil) ! fclose(mFile); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XLogFile::XLogFile ! // ! //--------------------------------------------------------------- ! XLogFile::XLogFile(const char* fileName): ! mFile (nil), ! mFailed (false) ! { ! #if TARGET_OS_MAC ! ProcessSerialNumber psn; ! OSStatus err = ::GetCurrentProcess(&psn); ! ! FSRef appRef; ! if (err == noErr) { ! err = ::GetProcessBundleLocation(&psn, &appRef); ! } ! ! FSRef parentRef; ! if (err == noErr) { ! err = ::FSGetCatalogInfo(&appRef, kFSCatInfoNone, nil, nil, nil, &parentRef); ! } ! ! MCFURL parentSpec (::CFURLCreateFromFSRef (kCFAllocatorDefault, &parentRef)); ! if (parentSpec != nil) { ! mSpec = OSFSSpec(::CFURLCreateWithFileSystemPathRelativeToBase (kCFAllocatorDefault, MCoreString (fileName), ! kCFURLPOSIXPathStyle, false, *parentSpec)); ! } ! ! #elif TARGET_OS_WIN32 ! // Get a path to the exe. ! uint32 succeeded = ::GetModuleFileNameA(GetModuleHandle(nil), mPath, sizeof(mPath)); ! if (succeeded) { ! ! // Find out where the app name starts. ! uint32 pos = ULONG_MAX; ! for (uint32 j = strlen(mPath) - 1; pos == ULONG_MAX && j < ULONG_MAX; --j) { ! if (mPath[j] == '\\') ! pos = j; ! } ! ! // Copy fileName over the app name. ! strcpy(mPath + pos + 1, fileName); ! } ! #endif ! } ! ! ! //--------------------------------------------------------------- ! // ! // XLogFile::Print (const char*, ...) ! // ! //--------------------------------------------------------------- ! void XLogFile::Print(const char* format, ...) ! { ! if (mFile == nil) ! this->DoOpen(); ! ! if (mFile != nil) { ! char mesg[2048]; ! ! va_list args; ! va_start(args, format); ! vsprintf(mesg, format, args); ! va_end(args); ! ! fprintf(mFile, "%s", mesg); ! } ! } ! ! ! //--------------------------------------------------------------- ! // ! // XLogFile::Print (const wchar_t*, ...) ! // ! //--------------------------------------------------------------- ! void XLogFile::Print(const wchar_t* format, ...) ! { ! if (mFile == nil) ! this->DoOpen(); ! ! if (mFile != nil) { ! wchar_t mesg[2048]; ! ! va_list args; ! va_start(args, format); ! vswprintf(mesg, sizeof(mesg)/sizeof(wchar_t), format, args); ! va_end(args); ! ! fprintf(mFile, "%ls", mesg); ! } ! } ! ! ! //--------------------------------------------------------------- ! // ! // XLogFile::Flush ! // ! //--------------------------------------------------------------- ! void XLogFile::Flush() ! { ! if (mFile != nil) ! fflush(mFile); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XLogFile::DoOpen ! // ! //--------------------------------------------------------------- ! void XLogFile::DoOpen() ! { ! if (!mFailed) { // don't attempt to re-open the file if we've already failed ! #if TARGET_OS_MAC ! mFailed = true; // Do not go into an infinite loop if opening a file causes use to print to the log file ! mFile = FSSpecOpen(mSpec, "w"); ! mFailed = false; ! ! if (mFile == nil) ! mFailed = true; ! #elif TARGET_OS_WIN32 ! if (mPath[0] != 0) { ! mFile = fopen(mPath, "w"); ! ! if (mFile == nil) ! mPath[0] = 0; ! #endif ! } ! ! if (mFile != nil) ! this->DoPrintTimeStamp(); ! } ! ! ! //--------------------------------------------------------------- ! // ! // XLogFile::DoPrintTimeStamp ! // ! //--------------------------------------------------------------- ! void XLogFile::DoPrintTimeStamp() ! { ! #if TARGET_OS_MAC ! // Get the current time ! LongDateCvt date; ! date.hl.lHigh = 0; ! ::GetDateTime(&date.hl.lLow); ! ! // Print the date ! Str255 str; ! ::LongDateString(&date.c, abbrevDate, str, nil); ! this->Print("Date: %#s\n", str); ! ! // Print the time ! ::LongTimeString(&date.c, true, str, nil); ! this->Print("Time: %#s\n\n", str); ! ! #elif TARGET_OS_WIN32 ! // Get the current time ! FILETIME date; ! SYSTEMTIME systemTime; ! ::GetLocalTime(&systemTime); ! ! int32 succeeded = ::SystemTimeToFileTime(&systemTime, &date); ! if (!succeeded) goto fail; ! ! // Print the date ! char buffer[2048]; ! ! int32 numChars = ::GetDateFormatA(nil, DATE_LONGDATE, &systemTime, nil, nil, 0); ! if (numChars == 0) goto fail; ! numChars = Min(numChars, (int32) sizeof(buffer)); ! ! succeeded = ::GetDateFormatA(nil, DATE_LONGDATE, &systemTime, nil, buffer, numChars); ! if (!succeeded) goto fail; ! ! this->Print("Date: %*s\n", numChars, buffer); ! ! // Print the time ! numChars = ::GetTimeFormatA(nil, 0UL, &systemTime, nil, nil, 0); ! if (numChars == 0) goto fail; ! numChars = Min(numChars, (int32) sizeof(buffer)); ! ! succeeded = ::GetTimeFormatA(nil, 0UL, &systemTime, nil, buffer, numChars); ! if (!succeeded) goto fail; ! ! this->Print("Time: %*s\n\n", numChars, buffer); ! ! return; ! ! fail: ! this->Print("Couldn't get the timestamp (error: %d)\n", GetLastError()); ! #endif ! } ! ! ! } // namespace Whisper --- 1,4 ---- ! /* * File: XLogFile.cpp * Summary: Dumps information out to a file in the app's folder. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * $Log$ ! /* * File: XLogFile.cpp * Summary: Dumps information out to a file in the app's folder. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Revision 1.7 2004/03/28 22:13:15 psnively ! /* * File: XLogFile.cpp * Summary: Dumps information out to a file in the app's folder. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. ! /* * File: XLogFile.cpp * Summary: Dumps information out to a file in the app's folder. * Written by: Jesse Jones * * Copyright © 1999-2001 Jesse Jones. * This code is distributed under the zlib/libpng license (see License.txt for details). * * Change History (most recent first): * * * Revision 1.6 2003/08/15 10:07:58 meeroh * Macro changes: * MAC -> TARGET_OS_MAC * WIN -> TARGET_OS_WIN32 * TARGET_CARBON -> TARGET_API_MAC_CARBON * BIG_ENDIAN -> TARGET_RT_BIG_ENDIAN * !BIG_ENDIAN -> TARGET_RT_LITTLE_ENDIAN * CODE_WARRIOR -> TARGET_CC_METROWERKS * __MWERKS__ -> TARGET_CC_METROWERKS * MSVC -> TARGET_CC_MICROSOFT * _MSC_VER -> TARGET_CC_MICROSOFT * #pragma mark ~ -> #pragma mark - * Added #ifdef PRAGMA_MARK * * Revision 1.5 2003/08/14 06:01:50 meeroh * Replaced FSSpecs with CFURLs/FSRefs * * Revision 1.4 2001/04/17 01:44:21 jesjones * Got rid of XInvariantMixin. * * Revision 1.3 2000/12/10 04:10:29 jesjones * Replaced int16_cast, uint32_cast, etc with numeric_cast. * * Revision 1.2 2000/11/09 12:42:28 jesjones * 1) Removed double CRs introduced during the initial checkin. 2) Changed the header comments to make it clearer that Whisper is using the zlib license agreement. 3) Added the Log keyword. */ #include <XWhisperHeader.h> #include <XLogFile.h> #include <XTranscode.h> #include <cstdarg> #include <cstdio> #include <XNumbers.h> namespace Whisper { using namespace std; // =================================================================================== // Internal Functions // =================================================================================== //--------------------------------------------------------------- // // FSSpecOpen // //--------------------------------------------------------------- #if TARGET_OS_MAC && TARGET_CC_METROWERKS #include <FSp_fopen.h> static FILE* FSSpecOpen(const OSFSSpec& spec, const char* mode) { OSFSSpec baseSpec(::CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, *spec)); FSRef baseRef; if (!::CFURLGetFSRef(*baseSpec, &baseRef)) { return nil; } MCoreString path = ::CFURLCopyLastPathComponent(*spec); HFSUniStr255 hfsPath = ToHFSUniStr(path.c_str()); return FSRefParentAndFilename_fopen(&baseRef, &hfsPath, mode); } #endif #if PRAGMA_MARK #pragma mark - #endif // =================================================================================== // class XLogFile // =================================================================================== //--------------------------------------------------------------- // // XLogFile::~XLogFile // //--------------------------------------------------------------- XLogFile::~XLogFile() { if (mFile != nil) fclose(mFile); } //--------------------------------------------------------------- // // XLogFile::XLogFile // //--------------------------------------------------------------- XLogFile::XLogFile(const char* fileName): mFile (nil), mFailed (false) { #if TARGET_OS_MAC ProcessSerialNumber psn; OSStatus err = ::GetCurrentProcess(&psn); FSRef appRef; if (err == noErr) { err = ::GetProcessBundleLocation(&psn, &appRef); } FSRef parentRef; if (err == noErr) { err = ::FSGetCatalogInfo(&appRef, kFSCatInfoNone, nil, nil, nil, &parentRef); } MCFURL parentSpec (::CFURLCreateFromFSRef (kCFAllocatorDefault, &parentRef)); if (parentSpec != nil) { mSpec = OSFSSpec(::CFURLCreateWithFileSystemPathRelativeToBase (kCFAllocatorDefault, MCoreString (fileName), kCFURLPOSIXPathStyle, false, *parentSpec)); } #elif TARGET_OS_WIN32 // Get a path to the exe. uint32 succeeded = ::GetModuleFileNameA(GetModuleHandle(nil), mPath, sizeof(mPath)); if (succeeded) { // Find out where the app name starts. uint32 pos = ULONG_MAX; for (uint32 j = strlen(mPath) - 1; pos == ULONG_MAX && j < ULONG_MAX; --j) { if (mPath[j] == '\\') pos = j; } // Copy fileName over the app name. strcpy(mPath + pos + 1, fileName); } #endif } //--------------------------------------------------------------- // // XLogFile::Print (const char*, ...) // //--------------------------------------------------------------- void XLogFile::Print(const char* format, ...) { if (mFile == nil) this->DoOpen(); if (mFile != nil) { char mesg[2048]; va_list args; va_start(args, format); vsprintf(mesg, format, args); va_end(args); fprintf(mFile, "%s", mesg); } } //--------------------------------------------------------------- // // XLogFile::Print (const wchar_t*, ...) // //--------------------------------------------------------------- void XLogFile::Print(const wchar_t* format, ...) { if (mFile == nil) this->DoOpen(); if (mFile != nil) { wchar_t mesg[2048]; va_list args; va_start(args, format); vswprintf(mesg, sizeof(mesg)/sizeof(wchar_t), format, args); va_end(args); fprintf(mFile, "%ls", mesg); } } //--------------------------------------------------------------- // // XLogFile::Flush // //--------------------------------------------------------------- void XLogFile::Flush() { if (mFile != nil) fflush(mFile); } //--------------------------------------------------------------- // // XLogFile::DoOpen // //--------------------------------------------------------------- void XLogFile::DoOpen() { if (!mFailed) { // don't attempt to re-open the file if we've already failed #if TARGET_OS_MAC mFailed = true; // Do not go into an infinite loop if opening a file causes use to print to the log file mFile = FSSpecOpen(mSpec, "w"); mFailed = false; if (mFile == nil) mFailed = true; #elif TARGET_OS_WIN32 if (mPath[0] != 0) { mFile = fopen(mPath, "w"); if (mFile == nil) mPath[0] = 0; } #endif } if (mFile != nil) this->DoPrintTimeStamp(); } //--------------------------------------------------------------- // // XLogFile::DoPrintTimeStamp // //--------------------------------------------------------------- void XLogFile::DoPrintTimeStamp() { #if TARGET_OS_MAC // Get the current time LongDateCvt date; date.hl.lHigh = 0; ::GetDateTime(&date.hl.lLow); // Print the date Str255 str; ::LongDateString(&date.c, abbrevDate, str, nil); this->Print("Date: %#s\n", str); // Print the time ::LongTimeString(&date.c, true, str, nil); this->Print("Time: %#s\n\n", str); #elif TARGET_OS_WIN32 // Get the current time FILETIME date; SYSTEMTIME systemTime; ::GetLocalTime(&systemTime); int32 succeeded = ::SystemTimeToFileTime(&systemTime, &date); if (!succeeded) goto fail; // Print the date char buffer[2048]; int32 numChars = ::GetDateFormatA(nil, DATE_LONGDATE, &systemTime, nil, nil, 0); if (numChars == 0) goto fail; numChars = Min(numChars, (int32) sizeof(buffer)); succeeded = ::GetDateFormatA(nil, DATE_LONGDATE, &systemTime, nil, buffer, numChars); if (!succeeded) goto fail; this->Print("Date: %*s\n", numChars, buffer); // Print the time numChars = ::GetTimeFormatA(nil, 0UL, &systemTime, nil, nil, 0); if (numChars == 0) goto fail; numChars = Min(numChars, (int32) sizeof(buffer)); succeeded = ::GetTimeFormatA(nil, 0UL, &systemTime, nil, buffer, numChars); if (!succeeded) goto fail; this->Print("Time: %*s\n\n", numChars, buffer); return; fail: this->Print("Couldn't get the timestamp (error: %d)\n", GetLastError()); #endif } } // namespace Whisper \ No newline at end of file |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:11
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Core Modified Files: Core.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Core.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Core/Core.mcp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 Binary files /tmp/cvsUdTmeS and /tmp/cvsiEPaNQ differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:11
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Core/Tester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Core/Tester Modified Files: CoreTester.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: CoreTester.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Core/Tester/CoreTester.mcp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 Binary files /tmp/cvsVDmBdn and /tmp/cvsCmI36l differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:11
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/Files Modified Files: Files.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Files.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Files.mcp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 Binary files /tmp/cvslqGED7 and /tmp/cvsVNzY46 differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:08
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/Plugins/C++ In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/COM/Tester/Plugins/C++ Modified Files: C++.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: C++.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/Plugins/C++/C++.mcp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 Binary files /tmp/cvsNLLBKe and /tmp/cvsJiBrXb differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:08
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/Plugins/Pascal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/COM/Tester/Plugins/Pascal Modified Files: Pascal.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Pascal.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/Plugins/Pascal/Pascal.mcp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 Binary files /tmp/cvscUP0iI and /tmp/cvseGggVF differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:08
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/Plugins/Asm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/COM/Tester/Plugins/Asm Modified Files: Asm.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Asm.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/Plugins/Asm/Asm.mcp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 Binary files /tmp/cvsaEgIhW and /tmp/cvsJTDCiT differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:07
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/COM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/COM Modified Files: COM.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: COM.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/COM/COM.mcp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 Binary files /tmp/cvsneGo2s and /tmp/cvsdH592o differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:07
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Source/BackEnd/COM/Tester Modified Files: COM Tester.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: COM Tester.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/COM/Tester/COM Tester.mcp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 Binary files /tmp/cvs8AB6LQ and /tmp/cvsZgVoWM differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:07
|
Update of /cvsroot/whisper2/Whisper/Examples/Project In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Examples/Project Modified Files: Examples.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Examples.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Examples/Project/Examples.mcp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsWd7Mlt and /tmp/cvscmvEMn differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:06
|
Update of /cvsroot/whisper2/Whisper/Examples/StringTableBuilder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Examples/StringTableBuilder Modified Files: StringTableBuilder.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: StringTableBuilder.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Examples/StringTableBuilder/StringTableBuilder.mcp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 Binary files /tmp/cvsJT3TJS and /tmp/cvs9727tN differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:06
|
Update of /cvsroot/whisper2/Whisper/Examples/DropSkeleton In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Examples/DropSkeleton Modified Files: DropSkeleton.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: DropSkeleton.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Examples/DropSkeleton/DropSkeleton.mcp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 Binary files /tmp/cvsgspBLq and /tmp/cvs21xSdl differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:06
|
Update of /cvsroot/whisper2/Whisper/Examples/XML Compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Examples/XML Compiler Modified Files: XML Compiler.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: XML Compiler.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Examples/XML Compiler/XML Compiler.mcp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 Binary files /tmp/cvsSBaAIz and /tmp/cvsXdiTZu differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:06
|
Update of /cvsroot/whisper2/Whisper/Project In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Project Modified Files: Whisper.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: Whisper.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Project/Whisper.mcp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsXSOpyE and /tmp/cvsMAjkRz differ |
|
From: Paul S. <psn...@us...> - 2004-03-28 22:25:06
|
Update of /cvsroot/whisper2/Whisper/Examples/DocSkeleton In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19418/Examples/DocSkeleton Modified Files: DocSkeleton.mcp Log Message: Minor code fixes to build on both Mac and Win32 again; fixes to project files to not cache like mad order things so precompiled headers work again. Index: DocSkeleton.mcp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Examples/DocSkeleton/DocSkeleton.mcp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 Binary files /tmp/cvsvwpPfE and /tmp/cvsCWd94x differ |
|
From: <psn...@us...> - 2003-11-05 14:29:38
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac
In directory sc8-pr-cvs1:/tmp/cvs-serv21252
Modified Files:
MFileDialog.cpp
Log Message:
Integrated Marshall's fixes.
Index: MFileDialog.cpp
===================================================================
RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac/MFileDialog.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** MFileDialog.cpp 13 Oct 2003 04:23:33 -0000 1.18
--- MFileDialog.cpp 5 Nov 2003 14:27:45 -0000 1.19
***************
*** 10,13 ****
--- 10,16 ----
*
* $Log$
+ * Revision 1.19 2003/11/05 14:27:45 psnively
+ * Integrated Marshall's fixes.
+ *
* Revision 1.18 2003/10/13 04:23:33 psnively
* Relaxed a bit to let "Document" be the default menu type again.
***************
*** 596,599 ****
--- 599,620 ----
// ===================================================================================
+ static void InitNavServicesFields ( XFileDialogOptions &options ) {
+ options.version = 0;
+ options.optionFlags = kNavDefaultNavDlogOptions;
+ options.location.h = options.location.v = -1;
+ options.clientName = nil;
+ options.windowTitle = nil;
+ options.actionButtonLabel = nil;
+ options.cancelButtonLabel = nil;
+ options.saveFileName = nil;
+ options.message = nil;
+ options.preferenceKey = 0L;
+ options.popupExtension = nil;
+ options.modality = kWindowModalityAppModal;
+ options.parentWindow = nil;
+ for ( int i = 0; i < sizeof ( options.reserved ) / sizeof ( options.reserved[0] ); ++i )
+ options.reserved [ i ] = 0;
+ }
+
//---------------------------------------------------------------
//
***************
*** 603,616 ****
XFileDialogOptions::XFileDialogOptions()
{
! if (MSystemInfo::HasNavServices()) {
OSStatus err = NavGetDefaultDialogCreationOptions(this);
ThrowIfOSErr(err);
-
- } else {
- std::memset(this, 0, sizeof(*this));
-
- location.h = -1;
- location.v = -1;
- }
clientName = theAppName.Get();
--- 624,633 ----
XFileDialogOptions::XFileDialogOptions()
{
! // Init the parent stuff
! ASSERT(MSystemInfo::HasNavServices());
! InitNavServicesFields (*this);
!
OSStatus err = NavGetDefaultDialogCreationOptions(this);
ThrowIfOSErr(err);
clientName = theAppName.Get();
***************
*** 757,761 ****
PRECONDITION(types.size() > 0);
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 774,778 ----
PRECONDITION(types.size() > 0);
! ASSERT(MSystemInfo::HasNavServices ());
ASSERT(msEventCallback != nil);
***************
*** 775,779 ****
OSStatus err = NavCreatePutFileDialog(const_cast<const XFileDialogOptions*>(&options),
msSelectedType, // first type will be the default
! msSelectedCreator, // maybe kNavGenericSignature?
msEventsUPP,
(void *)&types,
--- 792,796 ----
OSStatus err = NavCreatePutFileDialog(const_cast<const XFileDialogOptions*>(&options),
msSelectedType, // first type will be the default
! kNavGenericSignature , // maybe kNavGenericSignature?
msEventsUPP,
(void *)&types,
***************
*** 819,826 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 836,839 ----
***************
*** 839,843 ****
PRECONDITION(types.size() > 0);
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 852,856 ----
PRECONDITION(types.size() > 0);
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 875,879 ****
nil,
msFilterUPP,
! nil,
&navDialog);
--- 888,892 ----
nil,
msFilterUPP,
! (void *)&types,
&navDialog);
***************
*** 907,913 ****
NavDialogDispose(navDialog);
- } else
- DEBUGSTR("How'd we wind up here?");
-
return reply;
}
--- 920,923 ----
***************
*** 923,927 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 933,937 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 962,966 ****
nil,
msFilterUPP,
! nil,
&navDialog);
--- 972,976 ----
nil,
msFilterUPP,
! (void *)&types,
&navDialog);
***************
*** 995,1001 ****
NavDialogDispose(navDialog);
- } else
- DEBUGSTR("How'd we wind up here?");
-
return reply;
}
--- 1005,1008 ----
***************
*** 1014,1018 ****
PRECONDITION(types.size() > 0);
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1021,1025 ----
PRECONDITION(types.size() > 0);
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1083,1089 ****
NavDialogDispose(navDialog);
- } else
- DEBUGSTR("How'd we wind up here?");
-
return reply;
}
--- 1090,1093 ----
***************
*** 1099,1103 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1103,1107 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1152,1159 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1156,1159 ----
***************
*** 1169,1173 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1169,1173 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1215,1222 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1215,1218 ----
***************
*** 1232,1236 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1228,1232 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1281,1288 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1277,1280 ----
***************
*** 1311,1315 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
// ASSERT(msEventCallback != nil); // isn't true when in XApplication::OnLocateDataFolders...
--- 1303,1307 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
// ASSERT(msEventCallback != nil); // isn't true when in XApplication::OnLocateDataFolders...
***************
*** 1359,1366 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1351,1354 ----
***************
*** 1380,1385 ****
EAskSaveResult result = kCancelSave;
! OSErr err = noErr;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1368,1372 ----
EAskSaveResult result = kCancelSave;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1430,1475 ****
default:
result = kCancelSave;
- }
- } else {
- int16 item = kSaveBtn;
-
- MCreateModalFilterUPP theFilter(msModalFilter);
-
- if (MSystemInfo::HasAppearanceMgr()) {
- std::wstring defaultText = LoadWhisperString(L"Save (Button)"); // need to keep these in locals so they're not deleted before StandardAlert completes
- std::wstring cancelText = LoadWhisperString(L"Cancel (Button)");
- std::wstring otherText = LoadWhisperString(L"Don't Save (Button)");
-
- PascalString defaultStr = ToPascalStr(defaultText);
- PascalString cancelStr = ToPascalStr(cancelText);
- PascalString otherStr = ToPascalStr(otherText);
-
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = theFilter;
- params.defaultText = (unsigned char*) defaultStr.c_str();
- params.cancelText = (unsigned char*) cancelStr.c_str();
- params.otherText = (unsigned char*) otherStr.c_str();
- params.defaultButton = kSaveBtn;
- params.cancelButton = kCancelBtn;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- std::wstring errorStr = LoadWhisperString(L"File Ò#1Ó not saved.", docName);
- std::wstring supplementalStr = LoadWhisperString(L"Changes made to the file Ò#1Ó will be discarded if this file is not saved. Do you want to save changes to this file before closing it?", docName);
-
- err = StandardAlert(kAlertStopAlert, (unsigned char*) ToPascalStr(errorStr).c_str(), (unsigned char*) ToPascalStr(supplementalStr).c_str(), ¶ms, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
-
- } else {
- ParamText(ToPascalStr(docName).c_str(), "\p", "\p", "\p");
-
- item = CautionAlert(kSaveChangesAlert, theFilter);
- }
-
- if (item == kSaveBtn)
- result = kSaveChanges;
- else if (item == kDontSaveBtn)
- result = kDontSave;
}
--- 1417,1420 ----
***************
*** 1489,1494 ****
ERevertResult result = kCancelRevert;
! OSErr err = noErr;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1434,1438 ----
ERevertResult result = kCancelRevert;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1534,1569 ****
default:
result = kCancelRevert;
- }
- } else {
- int16 item = cancel;
-
- MCreateModalFilterUPP theFilter(msModalFilter);
-
- if (MSystemInfo::HasAppearanceMgr()) {
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = theFilter;
- params.defaultText = (StringPtr) -1L; // use default (ie "OK")
- params.cancelText = (StringPtr) -1L; // use default (ie "Cancel")
- params.otherText = nil;
- params.defaultButton = cancel;
- params.cancelButton = 0;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- std::wstring errorStr = LoadWhisperString(L"Revert changes to file Ò#1Ó.", docName);
- std::wstring supplementalStr = LoadWhisperString(L"Reverting file Ò#1Ó will discard all changes made to this file since you last saved it. Do you want to discard all changes to this file?", docName);
-
- err = StandardAlert(kAlertStopAlert, (unsigned char*) ToPascalStr(errorStr).c_str(), (unsigned char*) ToPascalStr(supplementalStr).c_str(), ¶ms, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
-
- } else {
- ParamText(ToPascalStr(docName).c_str(), "\p", "\p", "\p");
-
- item = CautionAlert(kConfirmRevertAlert, theFilter);
- }
-
- if (item == ok)
- result = kDiscardChanges;
}
--- 1478,1481 ----
***************
*** 1580,1584 ****
void XFileDialog::DoInit()
{
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventsUPP == nil);
ASSERT(msFilterUPP == nil);
--- 1492,1496 ----
void XFileDialog::DoInit()
{
! ASSERT (MSystemInfo::HasNavServices());
ASSERT(msEventsUPP == nil);
ASSERT(msFilterUPP == nil);
***************
*** 1589,1593 ****
msFilterUPP = NewNavObjectFilterUPP(XFileDialog::DoFilter);
ThrowIfMemFail(msFilterUPP);
- }
}
--- 1501,1504 ----
|
|
From: <psn...@us...> - 2003-10-29 01:10:15
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac In directory sc8-pr-cvs1:/tmp/cvs-serv23184 Modified Files: MFileSystem.cpp Log Message: Fixed obnoxious bug in ChangeCreatorType. Index: MFileSystem.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac/MFileSystem.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MFileSystem.cpp 15 Aug 2003 09:42:04 -0000 1.12 --- MFileSystem.cpp 29 Oct 2003 01:06:14 -0000 1.13 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.13 2003/10/29 01:06:14 psnively + * Fixed obnoxious bug in ChangeCreatorType. + * * Revision 1.12 2003/08/15 09:42:04 meeroh * FSCopyObject now returns OSStatus *************** *** 282,286 **** FSCatalogInfo catInfo; FileInfo* fileInfo = reinterpret_cast <FileInfo*> (&catInfo.finderInfo); ! file.GetCatalogInfo (kFSCatInfoDataSizes, &catInfo, nil, nil, nil); fileInfo->fileCreator = creator; --- 285,289 ---- FSCatalogInfo catInfo; FileInfo* fileInfo = reinterpret_cast <FileInfo*> (&catInfo.finderInfo); ! file.GetCatalogInfo (kFSCatInfoFinderInfo, &catInfo, nil, nil, nil); fileInfo->fileCreator = creator; |
|
From: <psn...@us...> - 2003-10-13 04:24:58
|
Update of /cvsroot/whisper2/Whisper/Examples/DropSkeleton/Source In directory sc8-pr-cvs1:/tmp/cvs-serv24784 Modified Files: CDropAppHelper.cpp Log Message: Changed dialogOptionFlags to optionFlags to reflect new API and data structures in Nav Services. Index: CDropAppHelper.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Examples/DropSkeleton/Source/CDropAppHelper.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CDropAppHelper.cpp 20 Aug 2003 07:46:06 -0000 1.6 --- CDropAppHelper.cpp 13 Oct 2003 04:24:51 -0000 1.7 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.7 2003/10/13 04:24:51 psnively + * Changed dialogOptionFlags to optionFlags to reflect new API and data structures in Nav Services. + * * Revision 1.6 2003/08/20 07:46:06 meeroh * Eliminated all occurrences of "using namespace" directives in header files to avoid namespace pollution, and adjusted the affected source files accordingly. *************** *** 127,131 **** #if TARGET_OS_MAC mOpenOptions.SetAppName(XFileSpec(MSystemInfo::GetAppFile()).GetName()); ! mOpenOptions.dialogOptionFlags = kNavNoTypePopup + kNavDontAutoTranslate + kNavDontAddTranslateItems; #endif --- 130,134 ---- #if TARGET_OS_MAC mOpenOptions.SetAppName(XFileSpec(MSystemInfo::GetAppFile()).GetName()); ! mOpenOptions.optionFlags = kNavNoTypePopup + kNavDontAutoTranslate + kNavDontAddTranslateItems; #endif |
|
From: <psn...@us...> - 2003-10-13 04:23:39
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac In directory sc8-pr-cvs1:/tmp/cvs-serv24562 Modified Files: MFileDialog.cpp Log Message: Relaxed a bit to let "Document" be the default menu type again. Index: MFileDialog.cpp =================================================================== RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac/MFileDialog.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MFileDialog.cpp 6 Oct 2003 03:39:07 -0000 1.17 --- MFileDialog.cpp 13 Oct 2003 04:23:33 -0000 1.18 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.18 2003/10/13 04:23:33 psnively + * Relaxed a bit to let "Document" be the default menu type again. + * * Revision 1.17 2003/10/06 03:39:07 psnively * Fixed obnoxiousness surrounding type menu in dialogs. *************** *** 772,776 **** OSStatus err = NavCreatePutFileDialog(const_cast<const XFileDialogOptions*>(&options), msSelectedType, // first type will be the default ! kNavGenericSignature, // was msSelectedCreator msEventsUPP, (void *)&types, --- 775,779 ---- OSStatus err = NavCreatePutFileDialog(const_cast<const XFileDialogOptions*>(&options), msSelectedType, // first type will be the default ! msSelectedCreator, // maybe kNavGenericSignature? msEventsUPP, (void *)&types, |