Re: [OT] files/dir on windoze
- Posted by "Elliott S. de Andrade" <quantum_analyst at hotmail.com> Jul 12, 2004
- 554 views
>From: Juergen Luethje <j.lue at gmx.de> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: [OT] files/dir on windoze >Date: Mon, 12 Jul 2004 09:33:35 +0200 > >Do you, or someone else, know a method, how an Euphoria program can >detect, what file system a given drive uses? > Here's a function that will do it. You just specify a drive letter ("C", "C:", "C:\\", or even "C:\\Documents and Settings\\") or a server drive location ("\\\\MyServer\\MyServedDrive\\"). It will return {DriveType, FileDirectoryComponent} DriveType is a string specifying FAT, NTFS, etc. FileDirectoryComponent is the maximum length of a "directory component" This is the maximum length of a bit between the slashes, ie a single file or directory name. I figure that might be interesting, though it probably only affects FAT systems without LFN.
include dll.e include machine.e constant kernel32 = open_dll("kernel32.dll"), lstrlen = define_c_func(kernel32, "lstrlenA", {C_POINTER}, C_ULONG), xGetVolumeInformation = define_c_func(kernel32, "GetVolumeInformationA", {C_POINTER, C_POINTER, C_ULONG, C_POINTER, C_POINTER, C_POINTER, C_POINTER, C_ULONG}, C_INT) global function getVolInfo(sequence drive) atom lpDrive, lpComponent, lpType integer ret sequence info if length(drive) = 1 then drive &= ":\\" else if equal(drive[1..2], "\\\\") then --server locations... if drive[length(drive)] != '\\' then drive &= '\\' end if else if length(drive) != 3 then drive = drive[1] & ":\\" end if end if end if lpDrive = allocate_string(drive) lpComponent = allocate(4) lpType = allocate(20) --? maybe longer... ret = c_func(xGetVolumeInformation, {lpDrive, NULL, 0, NULL, lpComponent, NULL, lpType, 20}) info = {peek({lpType, c_func(lstrlen, {lpType})}), peek4u(lpComponent)} free(lpDrive) free(lpComponent) free(lpType) return info end function --*** TEST *** printf(1, "%s:%d\n%s:%d\n%s:%d\n%s:%d\n", getVolInfo("C")&getVolInfo("D:")&getVolInfo("E:\\")&getVolInfo("F:\\"))
>Regards, > Juergen > ~[ WingZone ]~ http://wingzone.tripod.com/