Exemple #1
0
//-------------------------------------------------------------
// Pre     : If bCreateIntermediates is TRUE, create all eventually
//           missing parent directories too
// Post    : Return TRUE on success
// Task    : Create new directory
//-------------------------------------------------------------
bool CPath::DirectoryCreate(bool bCreateIntermediates /*= TRUE*/)
{
    std::string	PathText;
    bool	bSuccess;

    GetDriveDirectory(PathText);
    StripTrailingBackslash(PathText);
    bSuccess =::CreateDirectory(PathText.c_str(),NULL) != 0;
    if(!bSuccess)
    {
        CPath CurrentDir(CPath::CURRENT_DIRECTORY);
        bSuccess = ChangeDirectory() != 0;
        CurrentDir.ChangeDirectory();
    }

    if(!bSuccess && bCreateIntermediates)
    {
        std::string::size_type nDelimiter =PathText.rfind(DIRECTORY_DELIMITER);
        if(nDelimiter == std::string::npos)
            return FALSE;

        PathText.resize(nDelimiter + 1);
        CPath SubPath(PathText);

        if (SubPath.DirectoryCreate())
            return DirectoryCreate(false);
        else
            return FALSE;
    }

    return bSuccess;
}
Exemple #2
0
bool GatherTpp::MakeHtml(const char *folder, Gate2<int, int> progress) {
	DeleteFolderDeep(folder);
	DirectoryCreate(folder);

	for(int i = 0; i < tt.GetCount(); i++) {
		String topic = tt.GetKey(i);
		links.Add(topic, topic == indexTopic ? "index.html" :
		                 memcmp(topic, "topic://", 8) ? topic : TopicFileNameHtml(topic));
	}
	for(int i = 0; i < reflink.GetCount(); i++) {
		String l = reflink.GetKey(i);
		String lbl = Filter(l, CharFilterLbl);
		String f = links.Get(reflink[i], Null) + '#' + lbl;
		links.Add(l, f);
		static const char *x[] = { "::struct", "::class", "::union" };
		for(int ii = 0; ii < 3; ii++) {
			String e = x[ii];
			if(EndsWith(l, e)) {
				links.Add(l.Mid(0, l.GetLength() - e.GetLength()), f);
			}
		}
		labels.Add(l, lbl);
	}

	for(int i = 0; i < tt.GetCount(); i++) {
		if (progress(i+1, tt.GetCount()))
			return false;
		ExportPage(i, folder);
	}
	return true;
}
Exemple #3
0
void condor2nav::Download(const std::string &server, const bfs::path &url, const bfs::path &fileName, unsigned timeout /* = 30 */)
{
  DirectoryCreate(fileName.parent_path());
  bfs::ofstream out{fileName, std::ios_base::out | std::ios_base::binary};
  CIStream in{server, url.generic_string(), timeout};
  out << in;
}
Exemple #4
0
bool RealizeDirectory(const String& d)
#endif
{
	String dir = NormalizePath(d);
	Vector<String> p;
	while(dir.GetLength() > DIR_MIN) {
		p.Add(dir);
		dir = GetFileFolder(dir);
	}
	for(int i = p.GetCount() - 1; i >= 0; i--)
		if(!DirectoryExists(p[i]))
#ifdef POSIX
			if(!DirectoryCreate(p[i], mode))
#else
			if(!DirectoryCreate(p[i]))
#endif
				return false;
	return true;
}
Exemple #5
0
//------------------------------------------------------------------------------
/*static*/ bool FileIO::EnsurePathExists( const AString & path )
{
	// if the entire path already exists, nothing is to be done
	if( DirectoryExists( path ) )
	{
		return true;
	}

	// take a copy to locally manipulate
	AStackString<> pathCopy( path );
	PathUtils::FixupFolderPath( pathCopy ); // ensure correct slash type and termination

	// handle UNC paths by skipping leading slashes and machine name
    char * slash = pathCopy.Get();
	#if defined( __WINDOWS__ )
		if ( *slash == NATIVE_SLASH )
		{
			while ( *slash == NATIVE_SLASH ) { ++slash; } // skip leading double slash
			while ( *slash != NATIVE_SLASH ) { ++slash; } // skip machine name
			++slash; // move into first dir name, so next search will find dir name slash
		}
	#endif
	
    #if defined( __LINUX__ ) || defined( __APPLE__ )
        // for full paths, ignore the first slash
        if ( *slash == NATIVE_SLASH )
        {
            ++slash;
        }
    #endif

	slash = pathCopy.Find( NATIVE_SLASH, slash );
	if ( !slash )
	{
		return false;
	}
	do
	{
		// truncate the string to the sub path
		*slash = '\000';
		if ( DirectoryExists( pathCopy ) == false )
		{
			// create this level
			if ( DirectoryCreate( pathCopy ) == false )
			{
				return false; // something went wrong
			}
		}
		*slash = NATIVE_SLASH; // put back the slash
		slash = pathCopy.Find( NATIVE_SLASH, slash + 1 );
	}
	while ( slash );
	return true;
}