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 » Community » Newbie corner » Get volume name of shares ... (Try to get a shares volume name)
Re: Get volume name of shares ... [message #56252 is a reply to message #56222] Sun, 14 February 2021 14:21 Go to previous message
dschoni is currently offline  dschoni
Messages: 15
Registered: January 2021
Location: Switzerland
Promising Member
Dear Mirek

Quote:
Nope, you do Find with empty path and then you get it in FileInfo::root_desc.


This works on a fixed disk drive, but not on a network share.
I've tried:
void FolderTree::AddSystemPlaces(int id)
{
	Array<FileSystemInfo::FileInfo> root;
	FileSystemInfo fs;
#ifdef PLATFORM_WIN32
	root = fs.Find("",1000,false);
	for(int i = 0; i < root.GetCount(); i++) {
		String desc = root[i].root_desc;
		String n = root[i].filename;
		if(n != "A:\\" && n != "B:\\") {
		#ifdef PLATFORM_WIN32
			if(*n.Last() == '\\')
				n.Trim(n.GetCount() - 1);
		#endif
		    String type;
		    int maxName;
			if(desc.GetCount() == 0) {
				GetDriveInformation(n, type, desc, maxName, type);
				if (desc == "") desc << " " << t_("Local Disk");
			}
			desc << " (" << n << ")";
			AddPlace(id, GetDriveImage(root[i].root_style), root[i].filename, desc);
		}
	}

	if(GetSystemMetrics(SM_REMOTESESSION))
		for(int drive = 'A'; drive < 'Z'; drive++) {
			String path = Format("\\\\tsclient\\%c", drive);
			if(FindFile(path + "\\*.*"))
				AddPlace(id, path, Format(t_("%c on client"), drive));
		}
#endif

#ifdef PLATFORM_POSIX
	root = fs.Find("/media/*",1000,false);
	for(int i = 0; i < root.GetCount(); i++) {
		String fn = root[i].filename;
		if(*fn != '.' && fn.Find("floppy") < 0)
			AddPlace(id, "/media/" + fn, fn);
	}
	AddPlace(id, "/", t_("Computer"));
#endif
}


After
		String desc = root[i].root_desc;
		String n = root[i].filename;

"desc" contains the value "Document" at my fixed disk drive "D:" which is the volume name.
"n" contains "D:\\".

If I go further to "M:", which is a network share and the volume name is "Media", i've got:
"desc" contains "".
"n" contains "M:\\".

index.php?t=getfile&id=6375&private=0

This is why I've copied "GetDriveInformation" from the SysInfo-package to my code and used Quote:

GetDriveInformation(n, type, desc, maxName, type);
if "desc" is empty.

After "GetDriveInformation" "desc" contains "Media".

Best Regards, Daniel
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CallbackN<> storing pointer to member function
Next Topic: [Solved]Vector<Vector<int>> problem
Goto Forum:
  


Current Time: Thu May 09 23:40:31 CEST 2024

Total time taken to generate the page: 0.02049 seconds