platformVolume.cpp
Engine/source/platform/platformVolume.cpp
Namespaces:
namespace
namespace
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platform/platform.h" 25 26#if defined(TORQUE_OS_WIN) 27#include <sys/utime.h> 28#else 29#include <sys/time.h> 30#endif 31 32#include "platform/platformVolume.h" 33#include "core/util/zip/zipVolume.h" 34 35using namespace Torque; 36using namespace Torque::FS; 37 38namespace Platform 39{ 40namespace FS 41{ 42 43bool MountDefaults() 44{ 45 String path = getAssetDir(); 46 47 bool mounted = Mount( "game", createNativeFS( path )); 48 49 if ( !mounted ) 50 return false; 51 52#ifndef TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM 53 // Note that the VirtualMountSystem must be enabled in volume.cpp for zip support to work. 54 return MountZips("game"); 55#else 56 return true; 57#endif 58} 59 60bool MountZips(const String &root) 61{ 62 Path basePath; 63 basePath.setRoot(root); 64 Vector<String> outList; 65 66 S32 num = FindByPattern(basePath, "*.zip", true, outList); 67 if(num == 0) 68 return true; // not an error 69 70 S32 mounted = 0; 71 for(S32 i = 0;i < outList.size();++i) 72 { 73 String &zipfile = outList[i]; 74#ifdef TORQUE_ZIP_DISK_LAYOUT 75 mounted += (S32)Mount(root, new ZipFileSystem(zipfile, false)); 76#else 77 mounted += (S32)Mount(root, new ZipFileSystem(zipfile, true)); 78#endif 79 } 80 81 return mounted == outList.size(); 82} 83 84//----------------------------------------------------------------------------- 85 86bool Touch( const Path &path ) 87{ 88#if defined(TORQUE_OS_WIN) 89 return( utime( path.getFullPath(), 0 ) != -1 ); 90#else 91 return( utimes( path.getFullPath(), NULL) == 0 ); // utimes returns 0 on success. 92#endif 93} 94 95} // namespace FS 96} // namespace Platform 97