コード例 #1
0
ファイル: PhpSFTPHandler.cpp プロジェクト: lpc1996/codelite
void PhpSFTPHandler::DoSyncFileWithRemote(const wxFileName& localFile)
{
    // Check to see if we got a remote-upload setup
    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProjectForFile(localFile);
    if(!pProject) {
        // Not a workspace file
        clDEBUG() << localFile << "is not a PHP workspace file, will not sync it with remote" << clEndl;
        return;
    }

    SSHWorkspaceSettings workspaceSettings;
    workspaceSettings.Load();
    
    if(!EnsureAccountExists(workspaceSettings)) { return; }
    
    // Convert the local path to remote path
    wxString remotePath = GetRemotePath(workspaceSettings, localFile.GetFullPath());
    if(remotePath.IsEmpty()) { return; }

    // Fire this event, if the sftp plugin is ON, it will handle it
    clSFTPEvent eventSave(wxEVT_SFTP_SAVE_FILE);
    eventSave.SetAccount(workspaceSettings.GetAccount());
    eventSave.SetLocalFile(localFile.GetFullPath());
    eventSave.SetRemoteFile(remotePath);
    EventNotifier::Get()->AddPendingEvent(eventSave);
}
コード例 #2
0
ファイル: ToolManifest.cpp プロジェクト: zhangf911/fastbuild
// GetRemoteFilePath
//------------------------------------------------------------------------------
void ToolManifest::GetRemoteFilePath( uint32_t fileId, AString & exe, bool fullPath ) const
{
	// we'll store in the sub dir
	if ( fullPath )
	{
		GetRemotePath( exe );
	}
	else
	{
		exe.Clear();
	}

	// determine primary root
	const File & primaryFile = m_Files[ 0 ];
	AStackString<> primaryPath( primaryFile.m_Name.Get(), primaryFile.m_Name.FindLast( NATIVE_SLASH ) + 1 ); // include backslash

	const File & f = m_Files[ fileId ];
	if ( f.m_Name.BeginsWithI( primaryPath ) )
	{
		// file is in sub dir on master machine, so store with same relative location
		exe += ( f.m_Name.Get() + primaryPath.GetLength() );
	}
	else
	{
		// file is in some completely other directory, so put in same place as exe
		const char * lastSlash = f.m_Name.FindLast( NATIVE_SLASH );
		lastSlash = lastSlash ? lastSlash + 1 : f.m_Name.Get();
		exe += AStackString<>( lastSlash, f.m_Name.GetEnd() );
	}
}
コード例 #3
0
ファイル: syncmanager.cpp プロジェクト: ForNeVeR/leechcraft
	void SyncManager::handleDirectoriesToSyncUpdated (const QList<SyncerInfo>& infos)
	{
		QStringList paths;
		for (const auto& info : infos)
		{
			paths << info.LocalDirectory_;
			auto acc = AM_->GetAccountFromUniqueID (info.AccountId_);

			if (AccountID2Syncer_.contains (info.AccountId_))
			{
				auto syncer = AccountID2Syncer_ [info.AccountId_];
				if (syncer->GetLocalPath () == info.LocalDirectory_ &&
						syncer->GetRemotePath () == info.RemoteDirectory_)
					continue;
				else
				{

					//TODO update syncer
// 					syncer->stop ();
// 					AccountID2Syncer_.take (info.AccountId_)->deleteLater ();
				}
			}
			else
			{
				auto syncer = CreateSyncer (acc, info.LocalDirectory_, info.RemoteDirectory_);
				AccountID2Syncer_ [info.AccountId_] = syncer;
// 				syncer->start ();
			}
		}

		FilesWatcher_->updatePaths (paths);
	}
コード例 #4
0
bool CState::RefreshRemote()
{
	if (!m_pCommandQueue)
		return false;

	if (!IsRemoteConnected() || !IsRemoteIdle())
		return false;

	return ChangeRemoteDir(GetRemotePath(), _T(""), LIST_FLAG_REFRESH);
}
コード例 #5
0
ファイル: PhpSFTPHandler.cpp プロジェクト: lpc1996/codelite
void PhpSFTPHandler::OnFileRenamed(clFileSystemEvent& e)
{
    e.Skip();
    if(!PHPWorkspace::Get()->IsOpen()) { return; }

    SSHWorkspaceSettings settings;
    settings.Load();
    
    if(!EnsureAccountExists(settings)) { return; }
    
    wxString oldPath = GetRemotePath(settings, e.GetPath());
    wxString newPath = GetRemotePath(settings, e.GetNewpath());
    if(oldPath.IsEmpty() || newPath.IsEmpty()) { return; }

    clDEBUG() << "PHP SFTP: Renaming:" << oldPath << "->" << newPath;

    // Fire this event, if the sftp plugin is ON, it will handle it
    clSFTPEvent eventRename(wxEVT_SFTP_RENAME_FILE);
    eventRename.SetAccount(settings.GetAccount());
    eventRename.SetRemoteFile(oldPath);
    eventRename.SetNewRemoteFile(newPath);
    EventNotifier::Get()->AddPendingEvent(eventRename);
}
コード例 #6
0
ファイル: ToolManifest.cpp プロジェクト: ClxS/fastbuild
// GetRemoteFilePath
//------------------------------------------------------------------------------
void ToolManifest::GetRemoteFilePath( uint32_t fileId, AString & exe, bool fullPath ) const
{
	// we'll store in the sub dir
	if ( fullPath )
	{
		GetRemotePath( exe );
	}
	else
	{
		exe.Clear();
	}

	// determine primary root
	const File & primaryFile = m_Files[ 0 ];
	const File & f = m_Files[ fileId ];

	GetRelativePath( primaryFile.m_Name, f.m_Name, exe );
}
コード例 #7
0
ファイル: PhpSFTPHandler.cpp プロジェクト: lpc1996/codelite
void PhpSFTPHandler::OnFileDeleted(clFileSystemEvent& e)
{
    e.Skip();
    if(!PHPWorkspace::Get()->IsOpen()) { return; }

    SSHWorkspaceSettings settings;
    settings.Load();
    
    if(!EnsureAccountExists(settings)) { return; }
    
    const wxArrayString& paths = e.GetPaths();
    if(paths.IsEmpty()) { return; }
    
    for(size_t i = 0; i < paths.size(); ++i) {
        wxString remotePath = GetRemotePath(settings, paths.Item(i));
        if(remotePath.IsEmpty()) { return; }
        
        // Fire this event, if the sftp plugin is ON, it will handle it
        clSFTPEvent eventDelete(wxEVT_SFTP_DELETE_FILE);
        eventDelete.SetAccount(settings.GetAccount());
        eventDelete.SetRemoteFile(remotePath);
        EventNotifier::Get()->AddPendingEvent(eventDelete);
    }
}
コード例 #8
0
ファイル: ToolManifest.cpp プロジェクト: zhangf911/fastbuild
// Deserialize
//------------------------------------------------------------------------------
void ToolManifest::Deserialize( IOStream & ms )
{
	ms.Read( m_ToolId );

	ASSERT( m_Files.IsEmpty() );

	uint32_t numFiles( 0 );
	ms.Read( numFiles );
	m_Files.SetCapacity( numFiles );

	for ( size_t i=0; i<(size_t)numFiles; ++i )
	{		
		AStackString<> name;
		uint64_t timeStamp( 0 );
		uint32_t hash( 0 );
		uint32_t contentSize( 0 );
		ms.Read( name );
		ms.Read( timeStamp );
		ms.Read( hash );
		ms.Read( contentSize );
		m_Files.Append( File( name, timeStamp, hash, nullptr, contentSize ) );
	}

	// determine if any files are remaining from a previous run
	size_t numFilesAlreadySynchronized = 0;
	for ( size_t i=0; i<(size_t)numFiles; ++i )
	{
		AStackString<> localFile;
		GetRemoteFilePath( (uint32_t)i, localFile );

		// is this file already present?
		AutoPtr< FileStream > fileStream( FNEW( FileStream ) );
		FileStream & f = *( fileStream.Get() );
		if ( f.Open( localFile.Get() ) == false )
		{
			continue; // file not found
		}
		if ( f.GetFileSize() != m_Files[ i ].m_ContentSize )
		{
			continue; // file is not complete
		}
		AutoPtr< char > mem( (char *)ALLOC( (size_t)f.GetFileSize() ) );
		if ( f.Read( mem.Get(), (size_t)f.GetFileSize() ) != f.GetFileSize() )
		{
			continue; // problem reading file
		}
		if( Murmur3::Calc32( mem.Get(), (size_t)f.GetFileSize() ) != m_Files[ i ].m_Hash )
		{
			continue; // file contents unexpected
		}

		// file present and ok
		m_Files[ i ].m_FileLock = fileStream.Release(); // NOTE: keep file open to prevent deletions
		m_Files[ i ].m_SyncState = File::SYNCHRONIZED;
		numFilesAlreadySynchronized++;
	}

	// Generate Environment
	ASSERT( m_RemoteEnvironmentString == nullptr );

	// PATH=
	AStackString<> basePath;
	GetRemotePath( basePath );
	AStackString<> paths;
	paths.Format( "PATH=%s", basePath.Get() );

	// TMP=
	AStackString<> normalTmp;
	Env::GetEnvVariable( "TMP", normalTmp );
	AStackString<> tmp;
	tmp.Format( "TMP=%s", normalTmp.Get() );

	// SystemRoot=
	AStackString<> sysRoot( "SystemRoot=C:\\Windows" );

	char * mem = (char *)ALLOC( paths.GetLength() + 1 +
								  tmp.GetLength() + 1 +
								  sysRoot.GetLength() + 1 +
								  1 );
	m_RemoteEnvironmentString = mem;

	AString::Copy( paths.Get(), mem, paths.GetLength() + 1 ); // including null
	mem += ( paths.GetLength() + 1 ); // including null

	AString::Copy( tmp.Get(), mem, tmp.GetLength() + 1 ); // including null
	mem += ( tmp.GetLength() + 1 ); // including null

	AString::Copy( sysRoot.Get(), mem, sysRoot.GetLength() + 1 ); // including null
	mem += ( sysRoot.GetLength() + 1 ); // including null

	*mem = 0; ++mem; // double null

	// are all files already present?
	if ( numFilesAlreadySynchronized == m_Files.GetSize() )
	{
		m_Synchronized = true;		
	}
}