Exemplo n.º 1
0
bool ParzeLink( FSPath& path, FSString& link )
{
	FSPath t( link );

	if ( !path.IsAbsolute() && !t.IsAbsolute() ) { return false; } //не абсолютный путь

	int first = 0;

	if ( t.IsAbsolute() )
	{
		path.Clear();
		path.PushStr( FSString( "" ) );
		first = 1;
	}

	for ( int i = first; i < t.Count(); i++ )
	{
		FSString p = *( t.GetItem( i ) );

		if ( p.IsDot() ) { continue; }

		if ( p.Is2Dot() )
		{
			if ( path.Count() > 1 ) { path.Pop(); }
		}
		else
		{
			path.PushStr( p );
		}
	}

	return true;
}
Exemplo n.º 2
0
void OperCFThread::CreateDirectory( FS* fs, FSPath& srcPath, FSPath& destPath, bool processMultipleFolders )
{
	if ( processMultipleFolders )
	{
		const int DirIndex = srcPath.GetFirstUnmatchedItem( destPath );
		FSPath Path;

		for ( int i = 0; i < destPath.Count(); i++ )
		{
			// get next dir
			Path.PushStr( *destPath.GetItem( i ) );
			
			int ret_err;

			// try to create dir
			if ( i >= DirIndex && fs->MkDir( Path, 0777, &ret_err, Info() ) )
			{
				// skip "already exists" error
				if ( !fs->IsEEXIST( ret_err ) )
				{
					throw_msg( "%s", fs->StrError( ret_err ).GetUtf8() );
				}
			}
		}
	}
	else
	{
		int ret_err;

		if ( fs->MkDir( destPath, 0777, &ret_err, Info() ) )
		{
			throw_msg( "%s", fs->StrError( ret_err ).GetUtf8() );
		}
	}
}