From f42c8e06ddbca9c9954a21c8a3a15d52512a272e Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 8 Jan 2015 14:10:48 -0500 Subject: [PATCH] minor updates --- toolbox/os.cpp | 49 ++++++++++++++++++++++++++++++++++++- toolbox/os_hfs_dispatch.cpp | 2 +- toolbox/os_highlevel.cpp | 5 ---- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/toolbox/os.cpp b/toolbox/os.cpp index d05e0b7..dedaf58 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -836,6 +836,50 @@ namespace OS uint16_t HGetVInfo(uint16_t trap) { + + + /* + * The PBHGetVInfo function returns information about the specified + * volume. If the value of ioVolIndex is positive, the File Manager + * attempts to use it to find the volume; for instance, if the + * value of ioVolIndex is 2, the File Manager attempts to access + * the second mounted volume in the VCB queue. If the value of + * ioVolIndex is negative, the File Manager uses ioNamePtr and + * ioVRefNum in the standard way to determine the volume. If the + * value of ioVolIndex is 0, the File Manager attempts to access + * the volume by using ioVRefNum only. The volume reference number + * is returned in ioVRefNum, and the volume name is returned in + * the buffer whose address you passed in ioNamePtr. You should + * pass a pointer to a Str31 value if you want that name returned. + * If you pass NIL in the ioNamePtr field, no volume name is + * returned. + * + * If you pass a working directory reference number in ioVRefNum + * (or if the default directory is a subdirectory), the number + * of files and directories in the specified directory (the + * directory’s valence) is returned in ioVNmFls. + * + * You can read the ioVDrvInfo and ioVDRefNum fields to determine + * whether the specified volume is online, offline, or ejected. + * For online volumes, ioVDrvInfo contains the drive number of + * the drive containing the specified volume and hence is always + * greater than 0. If the value returned in ioVDrvInfo is 0, the + * volume is either offline or ejected. You can determine whether + * the volume is offline or ejected by inspecting the value of + * the ioVDRefNum field. For online volumes, ioVDRefNum contains + * a driver reference number; these numbers are always less than + * 0. If the volume is not online, the value of ioVDRefNum is + * either the negative of the drive number (if the volume is + * offline) or the drive number itself (if the volume is ejected). + * + * + * You can get information about all the online volumes by making + * repeated calls to PBHGetVInfo, starting with the value of + * ioVolIndex set to 1 and incrementing that value until PBHGetVInfo + * returns nsvErr. + */ + + enum { /* HVolumeParam */ _qLink = 0, @@ -880,7 +924,10 @@ namespace OS Log("%04x HGetVInfo(%08x)\n", trap, parm); - return MacOS::nsvErr; + d0 = MacOS::nsvErr; + memoryWriteWord(d0, parm + _ioResult); + + return d0; } diff --git a/toolbox/os_hfs_dispatch.cpp b/toolbox/os_hfs_dispatch.cpp index 1a5209d..31a9bb3 100644 --- a/toolbox/os_hfs_dispatch.cpp +++ b/toolbox/os_hfs_dispatch.cpp @@ -107,7 +107,7 @@ namespace OS { // and move to common internal code. - ToolBox::WritePString(ioNamePtr, std::string("MacOS")); + if (ioNamePtr) ToolBox::WritePString(ioNamePtr, std::string("MacOS")); memoryWriteWord(-1, parm + _ioVRefNum); memoryWriteLong(0, parm + _ioWDProcID); memoryWriteWord(-1, parm + _ioWDVRefNum); diff --git a/toolbox/os_highlevel.cpp b/toolbox/os_highlevel.cpp index 8506906..794435d 100644 --- a/toolbox/os_highlevel.cpp +++ b/toolbox/os_highlevel.cpp @@ -87,11 +87,6 @@ namespace OS { // expand the path. Also handles relative paths. char *cp = ::fs_spec_realpath(path.c_str(), buffer); - if (!cp) - { - fprintf(stderr, "realpath failed %s\n", path.c_str()); - return ""; - } return std::string(cp); }