Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Problem with DirectoryExists() in windows
Problem with DirectoryExists() in windows [message #21852] Mon, 08 June 2009 13:19 Go to next message
koldo is currently offline  koldo
Messages: 3358
Registered: August 2008
Senior Veteran
Hello all

When using DirectoryExists() with a drive name like

DirectoryExists("c:\\")


it returns false.

Revising the code I have seen that FindFirstFileW("C:\\") return INVALID_HANDLE_VALUE.

Perhaps a way to solve this would be check if directory name is a drive, so the changed DirectoryExists() could be:

bool DirectoryExists(const char *name) {
#if defined(PLATFORM_WIN32)
	if (GetDriveType(name) != DRIVE_NO_ROOT_DIR) 
	    return true;
#endif
	FindFile ff(name);
	return ff && ff.IsDirectory();
}


Best regards
Koldo


Best regards
IƱaki
Re: Problem with DirectoryExists() in windows [message #21859 is a reply to message #21852] Mon, 08 June 2009 14:35 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Good idea. I have only added check to be sure

bool DirectoryExists(const char *name) {
#if defined(PLATFORM_WIN32)
	if(name[0] && name[1] == ':' && name[2] == '\\' && name[3] == 0 &&
	   GetDriveType(name) != DRIVE_NO_ROOT_DIR) 
	    return true;
#endif
	FindFile ff(name);
	return ff && ff.IsDirectory();
}


Mirek
Previous Topic: [SOLVED] SHA1/MD5 encrypt example
Next Topic: EOL problem
Goto Forum:
  


Current Time: Mon Apr 29 14:04:20 CEST 2024

Total time taken to generate the page: 0.02698 seconds