driver GetDirListing, write logic, fixes

This commit is contained in:
Glenn Maynard
2003-12-05 02:25:32 +00:00
parent 6cd7d76358
commit ac004ea51a
6 changed files with 158 additions and 2 deletions
+35
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "RageFileDriver.h"
#include "RageUtil.h"
void RageFileObj::SetError( const CString &err )
{
@@ -58,6 +59,40 @@ int RageFileObj::GetFileSize()
return ret;
}
int RageFileDriver::GetPathValue( CString path )
{
vector<CString> parts;
split( path, SLASH, parts, true );
CString PartialPath;
for( unsigned i = 0; i < parts.size(); ++i )
{
PartialPath += parts[i];
if( i+1 < parts.size() )
PartialPath += SLASH;
const RageFileManager::FileType Type = GetFileType( PartialPath );
switch( Type )
{
case RageFileManager::TYPE_NONE:
return parts.size()-i;
/* If this is the last part (the whole path), it needs to be a file; otherwise a directory. */
case RageFileManager::TYPE_FILE:
if( i != parts.size()-1 )
return -1;
break;
case RageFileManager::TYPE_DIR:
if( i == parts.size()-1 )
return -1;
break;
}
}
return 0;
}
/*
* Copyright (c) 2003 by the person(s) listed below. All rights reserved.
* Glenn Maynard