// GetExtraOutputPath //------------------------------------------------------------------------------ void FunctionObjectList::GetExtraOutputPath( const AString * it, const AString * end, const char * option, AString & path ) const { const char * bodyStart = it->Get() + strlen( option ) + 1; // +1 for - or / const char * bodyEnd = it->GetEnd(); // if token is exactly matched then value is next token if ( bodyStart == bodyEnd ) { ++it; // handle missing next value if ( it == end ) { return; // we just pretend it doesn't exist and let the compiler complain } bodyStart = it->Get(); bodyEnd = it->GetEnd(); } // Strip quotes Args::StripQuotes( bodyStart, bodyEnd, path ); // If it's not already a path (i.e. includes filename.ext) then // truncate to just the path const char * lastSlash = path.FindLast( '\\' ); lastSlash = lastSlash ? lastSlash : path.FindLast( '/' ); lastSlash = lastSlash ? lastSlash : path.Get(); // no slash, means it's just a filename if ( lastSlash != ( path.GetEnd() - 1 ) ) { path.SetLength( uint32_t(lastSlash - path.Get()) ); } }
// CONSTRUCTOR //------------------------------------------------------------------------------ FileNode::FileNode( const AString & fileName, uint32_t controlFlags ) : Node( fileName, Node::FILE_NODE, controlFlags ) { ASSERT( fileName.EndsWith( "\\" ) == false ); ASSERT( ( fileName.FindLast( ':' ) == nullptr ) || ( fileName.FindLast( ':' ) == ( fileName.Get() + 1 ) ) ); m_LastBuildTimeMs = 1; // very little work required }
// GetFolderPath //------------------------------------------------------------------------------ void VSProjectGenerator::GetFolderPath( const AString & fileName, AString & folder ) const { const AString * const bEnd = m_BasePaths.End(); for ( const AString * bIt = m_BasePaths.Begin(); bIt != bEnd; ++bIt ) { const AString & basePath = *bIt; const char * begin = fileName.Get(); const char * end = fileName.GetEnd(); if ( fileName.BeginsWithI( basePath ) ) { begin = fileName.Get() + basePath.GetLength(); const char * lastSlash = fileName.FindLast( BACK_SLASH ); end = ( lastSlash ) ? lastSlash : end; if ( begin < end ) { folder.Assign( begin, end ); return; } } } // no matching base path (use root) folder.Clear(); }
// GetFolderIndexFor //------------------------------------------------------------------------------ uint32_t ProjectGeneratorBase::GetFolderIndexFor( const AString & path ) { // Get the path exluding the file file or dir const char * lastSlash = path.FindLast( NATIVE_SLASH ); if ( ( lastSlash == nullptr ) || ( lastSlash == path.Get() ) ) { return 0; // no sub-path: put it in the root } // Search for existing folder AStackString<> folderPath( path.Get(), lastSlash ); for ( const Folder& folder : m_Folders ) { if ( folder.m_Path == folderPath ) { return (uint32_t)( &folder - m_Folders.Begin() ); // Found existing } } // Add new folder(s) recursively const uint32_t parentFolderIndex = GetFolderIndexFor( folderPath ); // Create new folder Folder f; f.m_Path = folderPath; m_Folders.Append( f ); const uint32_t folderIndex = (uint32_t)( m_Folders.GetSize() - 1 ); // Add to parent folder m_Folders[ parentFolderIndex ].m_Folders.Append( folderIndex ); return folderIndex; }
// GetRelativePath //------------------------------------------------------------------------------ /*static*/ void ToolManifest::GetRelativePath( const AString & mainExe, const AString & otherFile, AString & otherFileRelativePath ) { // determine primary root AStackString<> primaryPath( mainExe.Get(), mainExe.FindLast( NATIVE_SLASH ) + 1 ); // include backslash if ( otherFile.BeginsWithI( primaryPath ) ) { // file is in sub dir on master machine, so store with same relative location otherFileRelativePath += ( otherFile.Get() + primaryPath.GetLength() ); } else { // file is in some completely other directory, so put in same place as exe const char * lastSlash = otherFile.FindLast( NATIVE_SLASH ); otherFileRelativePath += ( lastSlash ? lastSlash + 1 : otherFile.Get() ); } }
// EnsurePathExistsForFile //------------------------------------------------------------------------------ /*static*/ bool Node::EnsurePathExistsForFile( const AString & name ) { const char * lastSlash = name.FindLast( NATIVE_SLASH ); ASSERT( PathUtils::IsFullPath( name ) ); // should be guaranteed to be a full path AStackString<> pathOnly( name.Get(), lastSlash ); if ( FileIO::EnsurePathExists( pathOnly ) == false ) { FLOG_ERROR( "Failed to create path '%s'", pathOnly.Get() ); return false; } return true; }