home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 4.0 KB | 141 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSUUtil.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWSUUTIL_H
- #include "FWSUUtil.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Errors_defined
- #include <ErrorDef.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwodmisc
- #endif
-
- //========================================================================================
- // Storage Unit Utilities
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_SUAddPropValue
- //----------------------------------------------------------------------------------------
-
- void FW_SUAddPropValue(Environment* ev, ODStorageUnit* su, ODPropertyName prop, ODValueType val)
- {
- if (!su->Exists(ev, prop, NULL, 0))
- {
- su->AddProperty(ev, prop)->AddValue(ev, val);
- }
- else
- {
- su->Focus(ev, prop, kODPosUndefined, NULL, 0, kODPosUndefined);
- if (!su->Exists(ev, prop, val, 0))
- su->AddValue(ev, val);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_SURemoveValue
- //----------------------------------------------------------------------------------------
-
- void FW_SURemoveValue(Environment* ev, ODStorageUnit* su, ODPropertyName prop, ODValueType val)
- {
- if (su->Exists(ev, prop, val, 0))
- {
- su->Focus(ev, prop, kODPosUndefined, val, 0, kODPosUndefined);
- su->Remove(ev);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_SUClearValue
- //---------------------------------------------------------------------------------------
-
- void FW_SUClearValue(Environment* ev, ODStorageUnit* storageUnit, ODPropertyName prop, ODValueType val)
- {
- storageUnit->Focus(ev, prop, kODPosUndefined, val, 0, kODPosUndefined); // the offset if zero after focus
- unsigned long size = storageUnit->GetSize(ev);
- if (size != 0)
- storageUnit->DeleteValue(ev, size);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_SUDeleteEndOfFocusedValue
- //---------------------------------------------------------------------------------------
- // Assume focus on a property/value
-
- void FW_SUDeleteEndOfFocusedValue(Environment* ev, ODStorageUnit* storageUnit)
- {
- unsigned long toDelete = storageUnit->GetSize(ev) - storageUnit->GetOffset(ev);
- if (toDelete > 0)
- storageUnit->DeleteValue(ev, toDelete);
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_MacSUReadHFSFlavor
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_MacSUReadHFSFlavor(Environment* ev, ODStorageUnit* su, ODPropertyName prop, HFSFlavor& flavor)
- {
- ODTranslation *translate = su->GetSession(ev)->GetTranslation(ev);
- ODType applehfs = translate->GetISOTypeFromPlatformType(ev, 0x68667320UL, kODPlatformDataType); // 'hfs '
-
- if (FW_SUExistsThenFocus(ev, su, prop, applehfs))
- {
- FW_CByteArray byteArray;
- su->GetValue(ev, sizeof(HFSFlavor), byteArray);
- byteArray.CopyBuffer(&flavor, sizeof(HFSFlavor));
- return true;
- }
-
- return false;
- }
- #endif
-
-