Beispiel #1
0
// 2. Delegate file Uri to baseBS. Folder Uri is tmp:///folder/name#baseFSRootUri
//   - appears to work 
FSString FSTmp::Uri(FSPath& path)
{
	FSTmpNode* n = rootDir.findByFsPath(&path);
	if (n && n->nodeType == FSTmpNode::NODE_FILE)
		return baseFS->Uri(n->baseFSPath);
	else
	{
		std::string ret(std::string("tmp://") + path.GetUtf8('/') + "#" + baseFS->Uri(rootPathName).GetUtf8());
		return FSString(ret.c_str());
	}
}
Beispiel #2
0
void OperRDThread::Run()
{
	int n = 8;
	int ret_err;

	while (true) 
	{
		if (!(fs->Flags() & FS::HAVE_SYMLINK))
			break;
		
		FSStat st;

		if (fs->Stat(path, &st, &ret_err, Info()))
			throw_msg("%s", fs->StrError(ret_err).GetUtf8());
			
		if (!st.IsLnk()) 
			break;
		n--;
		if (n<0) 
			throw_msg("too more symbolic links '%s'", path.GetUtf8());
			
		path.Pop();
		if (!ParzeLink(path, st.link))
			throw_msg("invalid symbolic link '%s'", path.GetUtf8());
	}

	cptr<FSList> list = new FSList;
	int ret = fs->ReadDir(list.ptr(), path, &ret_err, Info());
	if (ret) 
		throw_msg("%s", fs->StrError(ret_err).GetUtf8());
	
	MutexLock lock(Node().GetMutex()); //!!!
	if (Node().NBStopped()) return;
	OperRDData *data = ((OperRDData*)Node().Data());
	data->list = list;
	data->path = path;
	data->executed = true;
}
Beispiel #3
0
FSString FSSmb::Uri( FSPath& path )
{
	MutexLock lock( &mutex );
	std::vector<char> a;

	if ( _param.server[0] )
	{
		if ( _param.user[0] )
		{
			a = carray_cat<char>( "smb://", const_cast<char*>( _param.user ), "@",  const_cast<char*>( _param.server ), path.GetUtf8() );
		}
		else
		{
			a = carray_cat<char>( "smb://", const_cast<char*>( _param.server ), path.GetUtf8() );
		}
	}
	else
	{
		a = carray_cat<char>( "smb:/", path.GetUtf8() );
	}

	return FSString( CS_UTF8, a.data() );
}
Beispiel #4
0
int64 FSSys::GetFileSystemFreeSpace( FSPath& path, int* err )
{
#if defined( __linux__ ) && !defined( __APPLE__ ) 
	struct statfs64 s;

	if ( statfs64( path.GetUtf8(), &s ) == -1 )
	{
		SetError( err, errno );
		return -1;
	}
#else
	// FreeBSD and probably other systems have 64 bit support in regular statfs
	struct statfs s;

	if ( statfs( path.GetUtf8(), &s ) == -1 )
	{
		SetError( err, errno );
		return -1;
	}
#endif

	return ( int64 )( s.f_bfree ) * ( int64 )( s.f_bsize );
}
FSString FSSftp::Uri( FSPath& path )
{
	MutexLock lock( &infoMutex ); //infoMutex!!!

	std::vector<char> a;

	char port[0x100];
	snprintf( port, sizeof( port ), ":%i", _infoParam.port );

	FSString server( _infoParam.server.Data() );

	FSString user( _infoParam.user.Data() );
	a = carray_cat<char>( "sftp://", user.GetUtf8(), "@",  server.GetUtf8(), port, path.GetUtf8( '/' ) );

	return FSString( CS_UTF8, a.data() );
}
Beispiel #6
0
void OperRDThread::Run()
{
	if ( !fs.Ptr() ) { return; }

	int n = 8;
	int ret_err;

	int havePostponedStatError = 0;
	FSString postponedStrError;

	while ( true )
	{
		if ( !( fs->Flags() & FS::HAVE_SYMLINK ) )
		{
			break;
		}

		FSStat st;

		// if path is inaccessible, try .. path. Throw the exception later
		// This makes panel at least having some valid folder
		while ( fs->Stat( path, &st, &ret_err, Info() ) )
		{
			havePostponedStatError = 1;
			postponedStrError = fs->StrError( ret_err );

			if ( !path.IsAbsolute() || path.Count() <= 1 || !path.Pop() )
			{
				throw_msg( "%s", postponedStrError.GetUtf8() );
			}
		}

		// yell immediately if the path is inaccessible (orig behavior)
		//if (fs->Stat(path, &st, &ret_err, Info()))
		// throw_msg("%s", fs->StrError(ret_err).GetUtf8());

		if ( !st.IsLnk() )
		{
			break;
		}

		n--;

		if ( n < 0 )
		{
			throw_msg( "too many symbolic links '%s'", path.GetUtf8() );
		}

		path.Pop();

		if ( !ParzeLink( path, st.link ) )
		{
			throw_msg( "invalid symbolic link '%s'", path.GetUtf8() );
		}
	}

	clPtr<FSList> list = new FSList;

	int havePostponedReadError = 0;

	// if directory is not readable, try .. path. Throw the exception later
	// "Stat" call above does not catch this: it checks only folder existence, but not accessibilly
	while ( fs->ReadDir( list.ptr(), path, &ret_err, Info() ) )
	{
		havePostponedReadError = 1;
		postponedStrError = fs->StrError( ret_err );

		if ( !path.IsAbsolute() || path.Count() <= 1 || !path.Pop() )
		{
			throw_msg( "%s", postponedStrError.GetUtf8() );
		}
	}

	// yell immediately if the dir is unreadable (orig behavior)
	//int ret = fs->ReadDir(list.ptr(), path, &ret_err, Info());
	//if (ret)
	// throw_msg("%s", fs->StrError(ret_err).GetUtf8());

	FSStatVfs vst;
	fs->StatVfs( path, &vst, &ret_err, Info() );

	MutexLock lock( Node().GetMutex() ); //!!!

	if ( Node().NBStopped() ) { return; }

	OperRDData* data = ( ( OperRDData* )Node().Data() );
	data->list = list;
	data->path = path;
	data->executed = true;
	data->vst = vst;

	if ( havePostponedReadError || havePostponedStatError )
	{
		data->nonFatalErrorString = postponedStrError;
	}
}
	virtual FSString Uri( FSPath& path ) override
	{
		FSPath FilePath( m_Uri );
		std::string ret( FilePath.GetItem( FilePath.Count() - 1 )->GetUtf8() + std::string( ":" ) + path.GetUtf8( '/' ) );
		return FSString( ret.c_str() );
	}