mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 11:01:03 +00:00
implement local mount point listing as drive listing under mingw
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21288 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8145bcc364
commit
b751d4b47f
2 changed files with 64 additions and 17 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-06-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSWorkspace.m: ([-mountedLocalVovumePaths]) implemented
|
||||||
|
for mingw as a listing of all device names.
|
||||||
|
|
||||||
2005-06-06 Adrian Robert <arobert@cogsci.ucsd.edu>
|
2005-06-06 Adrian Robert <arobert@cogsci.ucsd.edu>
|
||||||
|
|
||||||
* Headers/AppKit/NSApplication.h
|
* Headers/AppKit/NSApplication.h
|
||||||
|
|
|
@ -1215,11 +1215,15 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
||||||
|
|
||||||
- (NSArray*) mountedRemovableMedia
|
- (NSArray*) mountedRemovableMedia
|
||||||
{
|
{
|
||||||
NSArray *volumes = [self mountedLocalVolumePaths];
|
NSArray *volumes;
|
||||||
NSMutableArray *names = [NSMutableArray arrayWithCapacity: [volumes count]];
|
NSMutableArray *names;
|
||||||
|
unsigned count;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < [volumes count]; i++)
|
volumes = [self mountedLocalVolumePaths];
|
||||||
|
count = [volumes count];
|
||||||
|
names = [NSMutableArray arrayWithCapacity: count];
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
BOOL removableFlag;
|
BOOL removableFlag;
|
||||||
BOOL writableFlag;
|
BOOL writableFlag;
|
||||||
|
@ -1244,12 +1248,50 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
||||||
|
|
||||||
- (NSArray*) mountedLocalVolumePaths
|
- (NSArray*) mountedLocalVolumePaths
|
||||||
{
|
{
|
||||||
|
NSMutableArray *names;
|
||||||
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
|
#ifdef __MINGW__
|
||||||
|
unsigned max = BUFSIZ;
|
||||||
|
unichar buf[max];
|
||||||
|
unichar *base = buf;
|
||||||
|
unichar *ptr;
|
||||||
|
unichar *end;
|
||||||
|
unsigned len;
|
||||||
|
|
||||||
|
len = GetLogicalDriveStringsW(max-1, base);
|
||||||
|
while (len >= max)
|
||||||
|
{
|
||||||
|
base = NSZoneMalloc(NSDefaultMallocZone(), (len+1) * sizeof(unichar));
|
||||||
|
max = len;
|
||||||
|
len = GetLogicalDriveStringsW(max-1, base);
|
||||||
|
}
|
||||||
|
for (ptr = base; *ptr != 0; ptr = end + 1)
|
||||||
|
{
|
||||||
|
NSString *path;
|
||||||
|
|
||||||
|
end = ptr;
|
||||||
|
while (*end != 0)
|
||||||
|
{
|
||||||
|
end++;
|
||||||
|
}
|
||||||
|
len = (end - ptr) * sizeof(unichar);
|
||||||
|
path = [mgr stringWithFileSystemRepresentation: (char*)ptr length: len];
|
||||||
|
[names addObject: path];
|
||||||
|
}
|
||||||
|
if (base != buf)
|
||||||
|
{
|
||||||
|
NSZoneFree(NSDefaultMallocZone(), base);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
// FIXME This is system specific
|
// FIXME This is system specific
|
||||||
NSString *mtab = [NSString stringWithContentsOfFile: @"/etc/mtab"];
|
NSString *mtab = [NSString stringWithContentsOfFile: @"/etc/mtab"];
|
||||||
NSArray *mounts = [mtab componentsSeparatedByString: @"\n"];
|
NSArray *mounts = [mtab componentsSeparatedByString: @"\n"];
|
||||||
NSMutableArray *names = [NSMutableArray arrayWithCapacity: [mounts count]];
|
NSMutableArray *names;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
names = [NSMutableArray arrayWithCapacity: [mounts count]];
|
||||||
for (i = 0; i < [mounts count]; i++)
|
for (i = 0; i < [mounts count]; i++)
|
||||||
{
|
{
|
||||||
NSString *mount = [mounts objectAtIndex: i];
|
NSString *mount = [mounts objectAtIndex: i];
|
||||||
|
@ -1271,7 +1313,7 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue