Пример #1
0
//----------------------------------------------------------------//
void USLuaSerializer::SerializeToFile ( cc8* filename ) {

	USFileStream fileStream;
	fileStream.OpenWrite ( filename );
		
	this->SerializeToStream ( fileStream );
}
Пример #2
0
//----------------------------------------------------------------//
bool USData::Save ( cc8* filename, bool affirm_path ) {

	USFileStream out;

	if ( !out.OpenWrite ( filename, affirm_path ) ) return false;

	this->mMutex.Lock ();
	out.WriteBytes ( this->mBytes , this->mBytes.Size ());
	this->mMutex.Unlock ();

	return true;
}
Пример #3
0
//----------------------------------------------------------------//
bool USFileSys::Copy ( cc8* path, cc8* newPath ) {

	zl_stat fileStat;

	if ( !USFileSys::GetFileStat ( path, fileStat )) return false;
	if ( !fileStat.mExists ) return false;

	if ( fileStat.mIsDir ) {
		
		bool result = true;
		
		STLString cwd = USFileSys::GetCurrentPath ();
		STLString toPath = USFileSys::GetAbsoluteDirPath ( newPath );
		
		USFileSys::AffirmPath ( toPath );
		
		USFileSys::SetCurrentPath ( path );
		
		ZLDIR* itr = zl_dir_open ();
		if ( itr ) {
			while ( zl_dir_read_entry ( itr )) {
				cc8* entry = zl_dir_entry_name ( itr );
				if ( strcmp ( entry, "." ) == 0 ) continue;
				if ( strcmp ( entry, ".." ) == 0 ) continue;
				
				STLString destEntry = toPath;
				destEntry.append ( entry );
				
				if ( !USFileSys::Copy ( entry, destEntry )) {
					result = false;
					break;
				}
			}
			zl_dir_close ( itr );
		}
		USFileSys::SetCurrentPath ( cwd );
		
		return result;
	}
	else {
		USFileStream infile;
		if ( infile.OpenRead ( path )) {
		
			USFileStream outfile;
			if ( outfile.OpenWrite ( newPath )) {
				outfile.WriteStream ( infile );
				return true;
			}
		}
	}
	
	return false;
}