mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 06:38:01 +03:00
Directory exists, file exists checks separation
This commit is contained in:
parent
4463739be5
commit
d71041bfcf
@ -138,15 +138,7 @@ namespace Steamworks.Ugc
|
|||||||
//
|
//
|
||||||
// Checks
|
// Checks
|
||||||
//
|
//
|
||||||
if ( ContentFolder != null )
|
PerformValidityChecks();
|
||||||
{
|
|
||||||
if ( !System.IO.Directory.Exists( ContentFolder.FullName ) )
|
|
||||||
throw new System.Exception( $"UgcEditor - Content Folder doesn't exist ({ContentFolder.FullName})" );
|
|
||||||
|
|
||||||
if ( !ContentFolder.EnumerateFiles( "*", System.IO.SearchOption.AllDirectories ).Any() )
|
|
||||||
throw new System.Exception( $"UgcEditor - Content Folder is empty" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Item Create
|
// Item Create
|
||||||
@ -283,6 +275,29 @@ namespace Steamworks.Ugc
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PerformValidityChecks()
|
||||||
|
{
|
||||||
|
if ( ContentFolder == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
var fileAttributes = System.IO.File.GetAttributes( ContentFolder.FullName );
|
||||||
|
var isFolder = fileAttributes.HasFlag( System.IO.FileAttributes.Directory );
|
||||||
|
|
||||||
|
if ( isFolder )
|
||||||
|
{
|
||||||
|
if ( !ContentFolder.Exists )
|
||||||
|
throw new System.Exception( $"UgcEditor - Content Folder doesn't exist ({ContentFolder.FullName})" );
|
||||||
|
|
||||||
|
if ( !ContentFolder.EnumerateFiles( "*", System.IO.SearchOption.AllDirectories ).Any() )
|
||||||
|
throw new System.Exception( $"UgcEditor - Content Folder is empty" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !ContentFolder.Exists )
|
||||||
|
throw new System.Exception( $"UgcEditor - Content Path for file doesn't exist ({ContentFolder.FullName})" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct PublishResult
|
public struct PublishResult
|
||||||
|
Loading…
x
Reference in New Issue
Block a user