mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 16:20:58 +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>
|
||||
|
||||
* Headers/AppKit/NSApplication.h
|
||||
|
|
|
@ -1215,25 +1215,29 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
|||
|
||||
- (NSArray*) mountedRemovableMedia
|
||||
{
|
||||
NSArray *volumes = [self mountedLocalVolumePaths];
|
||||
NSMutableArray *names = [NSMutableArray arrayWithCapacity: [volumes count]];
|
||||
unsigned i;
|
||||
NSArray *volumes;
|
||||
NSMutableArray *names;
|
||||
unsigned count;
|
||||
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 writableFlag;
|
||||
BOOL unmountableFlag;
|
||||
NSString *description;
|
||||
NSString *fileSystemType;
|
||||
NSString *name = [volumes objectAtIndex: i];
|
||||
BOOL removableFlag;
|
||||
BOOL writableFlag;
|
||||
BOOL unmountableFlag;
|
||||
NSString *description;
|
||||
NSString *fileSystemType;
|
||||
NSString *name = [volumes objectAtIndex: i];
|
||||
|
||||
if ([self getFileSystemInfoForPath: name
|
||||
isRemovable: &removableFlag
|
||||
isWritable: &writableFlag
|
||||
isUnmountable: &unmountableFlag
|
||||
description: &description
|
||||
type: &fileSystemType] && removableFlag)
|
||||
isRemovable: &removableFlag
|
||||
isWritable: &writableFlag
|
||||
isUnmountable: &unmountableFlag
|
||||
description: &description
|
||||
type: &fileSystemType] && removableFlag)
|
||||
{
|
||||
[names addObject: name];
|
||||
}
|
||||
|
@ -1244,12 +1248,50 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
|||
|
||||
- (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
|
||||
NSString *mtab = [NSString stringWithContentsOfFile: @"/etc/mtab"];
|
||||
NSArray *mounts = [mtab componentsSeparatedByString: @"\n"];
|
||||
NSMutableArray *names = [NSMutableArray arrayWithCapacity: [mounts count]];
|
||||
NSMutableArray *names;
|
||||
unsigned int i;
|
||||
|
||||
names = [NSMutableArray arrayWithCapacity: [mounts count]];
|
||||
for (i = 0; i < [mounts count]; i++)
|
||||
{
|
||||
NSString *mount = [mounts objectAtIndex: i];
|
||||
|
@ -1271,7 +1313,7 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return names;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue