+
#include "global.h"
#include "RageFileManager.h"
#include "RageFileDriver.h"
return iRet;
}
+CString RageFileManager::ResolvePath( const CString &sPath_ )
+{
+ CString sPath = sPath_;
+ NormalizePath( sPath );
+
+ CString sResolvedPath = "";
+
+ vector<LoadedDriver *> apDriverList;
+ ReferenceAllDrivers( apDriverList );
+
+ for( unsigned i = 0; i < apDriverList.size(); ++i )
+ {
+ LoadedDriver *pDriver = apDriverList[i];
+
+ if( pDriver->m_sType == "mountpoints" )
+ continue;
+
+ const CString p = pDriver->GetPath(sPath);
+
+ if( p.empty() )
+ continue;
+
+ sResolvedPath = pDriver->m_sRoot + p;
+
+ LOG->Debug( "p: %s, pDriver->m_sRoot: %s, sResolvedPath: %s",
+ p.c_str(), pDriver->m_sRoot.c_str(), sResolvedPath.c_str() );
+
+ break;
+ }
+
+ UnreferenceAllDrivers( apDriverList );
+
+ NormalizePath( sResolvedPath );
+ LOG->Debug( "\"%s\" resolved to \"%s\".", sPath_.c_str(), sResolvedPath.c_str() );
+
+ return sResolvedPath;
+}
+
static bool SortBySecond( const pair<int,int> &a, const pair<int,int> &b )
{
return a.second < b.second;
int GetFileSizeInBytes( const CString &sPath );
int GetFileHash( const CString &sPath );
+ CString ResolvePath( const CString &sPath );
+
bool Mount( const CString &Type, const CString &RealPath, const CString &MountPoint, bool bAddToEnd = true );
void Unmount( const CString &Type, const CString &Root, const CString &MountPoint );
LOG = new RageLog();
/* Whew--we should be able to crash safely now! */
- LOG->Info( "%llu MB total, %llu MB remaining.",
- HOOKS->GetDiskSpaceTotal( argv[0] ) / (1024*1024),
- HOOKS->GetDiskSpaceFree( argv[0] ) / (1024*1024)
+ LOG->Info( "%llu bytes total, %llu bytes remaining.",
+ HOOKS->GetDiskSpaceTotal( "UserPacks" ),
+ HOOKS->GetDiskSpaceFree( "UserPacks" )
);
//
#include "Foreach.h"
#include "RageLog.h"
#include "RageFileDriverZip.h"
+#include "arch/ArchHooks/ArchHooks.h"
UserPackManager* UPACKMAN = NULL; // global and accessable from anywhere in our program
bool UserPackManager::IsPackTransferable( const CString sPack, CString &sError )
{
+
+
CStringArray asSavedPacks;
GetUserPacks( asSavedPacks );
for ( unsigned i = 0; i < asSavedPacks.size(); i++ )
/* Restart the entire computer, in case of installation updates, etc. */
virtual void SystemReboot( bool bForceSync = true ) { }
- /* Get API-specific machine information about the system
- * which contains the given file or directory path. */
- virtual uint64_t GetDiskSpaceTotal( const CString &sPath ) { return 0; }
- virtual uint64_t GetDiskSpaceFree( const CString &sPath ) { return 0; }
+ /* Get disk space from the device that contains the given directory.
+ * The path given is in the VFS; we resolve the actual path here. */
+ virtual uint64_t GetDiskSpaceTotal( const CString &sDir ) { return 0; }
+ virtual uint64_t GetDiskSpaceFree( const CString &sDir ) { return 0; }
/* Call this to temporarily enter a high-priority or realtime scheduling (depending
* on the implementation) mode. This is used to improve timestamp accuracy. Do as
#endif // ITG_ARCADE
}
-uint64_t ArchHooks_Unix::GetDiskSpaceTotal( const CString &sPath )
+static void GetDiskSpace( const CString &sDir, uint64_t *pSpaceFree, uint64_t *pSpaceTotal )
{
+ CString sResolvedDir = FILEMAN->ResolvePath( sDir );
+
struct statvfs fsdata;
- if( statvfs(sPath.c_str(), &fsdata) != 0 )
+ if( statvfs(sResolvedDir.c_str(), &fsdata) != 0 )
{
- LOG->Warn( "GetDiskSpaceTotal(): statvfs() failed: %s", strerror(errno) );
- return 0;
+ LOG->Warn( "GetDiskSpace(): statvfs() failed: %s", strerror(errno) );
+ return;
}
- // return blocksize x blocks available
- return uint64_t(fsdata.f_frsize) * uint64_t(fsdata.f_blocks);
+ // block size * blocks available to user
+ if ( pSpaceFree )
+ *pSpaceFree = uint64_t(fsdata.f_bsize) * uint64_t(fsdata.f_bavail);
+
+ // fragment size * blocks on the FS
+ if( pSpaceTotal )
+ *pSpaceTotal = uint64_t(fsdata.f_frsize) * uint64_t(fsdata.f_blocks);
}
-uint64_t ArchHooks_Unix::GetDiskSpaceFree( const CString &sPath )
+uint64_t ArchHooks_Unix::GetDiskSpaceFree( const CString &sDir )
{
- struct statvfs fsdata;
- if( statvfs(sPath.c_str(), &fsdata) != 0 )
- {
- LOG->Warn( "GetDiskSpaceTotal(): statvfs() failed: %s", strerror(errno) );
- return 0;
- }
+ uint64_t iSpaceFree = 0;
+ GetDiskSpace( sDir, &iSpaceFree, NULL );
+ return iSpaceFree;
+}
- // return blocksize x blocks available
- return uint64_t(fsdata.f_frsize) * uint64_t(fsdata.f_bfree);
+uint64_t ArchHooks_Unix::GetDiskSpaceTotal( const CString &sDir )
+{
+ uint64_t iSpaceTotal = 0;
+ GetDiskSpace( sDir, NULL, &iSpaceTotal );
+ return iSpaceTotal;
}
bool ArchHooks_Unix::OpenMemoryRange( unsigned short start_port, unsigned short bytes )
{
LOG->Trace( "ArchHooks_Unix::OpenMemoryRange( %#x, %d )", start_port, bytes );
-/* XXX: this does not work at all for the MK3 driver. Why not? */
-#if 0
- if( (start_port+bytes) <= 0x3FF )
- {
- int ret = ioperm( start_port, bytes, 1 );
-
- if( ret != 0 )
- LOG->Warn( "OpenMemoryRange(): ioperm error: %s", strerror(errno) );
-
- return (ret == 0);
- }
-
- LOG->Warn( "ArchHooks_Unix::OpenMemoryRange(): address range extends past ioperm, using iopl." );
-#endif
-
int ret = iopl(3);
if( ret != 0 )
sIP = inet_ntoa(((struct sockaddr_in *)sad)->sin_addr);
sNetmask = inet_ntoa(((struct sockaddr_in *)snm)->sin_addr);
}
+
freeifaddrs(ifaces);
- if( sIP.empty() || sNetmask.empty() )
+ if( sIP.empty() && sNetmask.empty() )
{
sError = "Networking interface disabled";
return false;
void BoostThreadPriority();
void UnBoostThreadPriority();
- uint64_t GetDiskSpaceTotal( const CString &sPath );
- uint64_t GetDiskSpaceFree( const CString &sPath );
+ uint64_t GetDiskSpaceTotal( const CString &sDir );
+ uint64_t GetDiskSpaceFree( const CString &sDir );
bool OpenMemoryRange( unsigned short start_port, unsigned short bytes );
void CloseMemoryRange( unsigned short start_port, unsigned short bytes );
return 0;
}
-uint64_t ArchHooks_Win32::GetDiskSpaceFree( const CString &sPath )
+static void GetDiskSpace( const CString &sDir, uint64_t *pSpaceFree, uint64_t *pSpaceTotal )
{
- return 0;
+ if( ::GetDiskSpaceFreeEx( sDir.c_str(), pSpaceFree, pSpaceTotal, NULL ) != 0 )
+ LOG->Warn( werr_ssprintf(GetLastError(), "GetDiskSpace() failed") );
+}
+
+uint64_t ArchHooks_Win32::GetDiskSpaceFree( const CString &sDir )
+{
+ uint64_t iDiskSpaceFree;
+ GetDiskSpace( sDir, &iDiskSpaceFree, NULL );
+ return iDiskSpaceFree;
+}
+
+uint64_t ArchHooks_Win32::GetDiskSpaceTotal( const CString &sDir )
+{
+ uint64_t iDiskSpaceTotal;
+ GetDiskSpace( sDir, NULL, &iDiskSpaceTotal );
+ return iDiskSpaceTotal;
}
bool ArchHooks_Win32::OpenMemoryRange( unsigned short start_port, unsigned short bytes )
void RestartProgram();
void SystemReboot( bool bForceSync = true );
- uint64_t GetDiskSpaceTotal( const CString &sPath );
- uint64_t GetDiskSpaceFree( const CString &sPath );
+ uint64_t GetDiskSpaceTotal( const CString &sDir );
+ uint64_t GetDiskSpaceFree( const CString &sDir );
int OldThreadPriority;
RageMutex *TimeCritMutex;
#include "global.h"
#include "io/G15.h"
#include "RageLog.h"
+#include "RageUtil.h"
void PixmapToLCDData( const unsigned char *pData, unsigned char *pLCD )
{
}
}
-/* right now, only supports G15 V2 keyboards */
+struct ID
+{
+ int VID, PID;
+};
+
+const ID DeviceIDs[2] =
+{
+ { 0x046D, 0xC227 },
+ { 0x046D, 0xC251 },
+};
+
bool G15::Matches( int idVendor, int idProduct ) const
{
- if ( idVendor != 0x046d ) return false;
- if ( idProduct != 0xc227 ) return false;
- return true;
+ for( unsigned i = 0; i < ARRAYSIZE(DeviceIDs); ++i )
+ if( idVendor == DeviceIDs[i].VID && idProduct == DeviceIDs[i].PID )
+ return true;
+
+ return false;
}
bool G15::WriteLCD( unsigned char *pData )