driver GetDirListing, write logic, fixes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user