2 * Implement routines to determine drive type (Windows specific).
4 * Written by Robert Nelson, June 2006
10 Copyright (C) 2006 Kern Sibbald
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 version 2 as amended with additional clauses defined in the
15 file LICENSE in the main source directory.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 the file LICENSE for additional details.
29 #else /* Set up for testing a stand alone program */
34 #define SUPPORTEDOSES \
38 #define bstrncpy strncpy
39 #define Dmsg0(n,s) fprintf(stderr, s)
40 #define Dmsg1(n,s,a1) fprintf(stderr, s, a1)
41 #define Dmsg2(n,s,a1,a2) fprintf(stderr, s, a1, a2)
45 * These functions should be implemented for each OS
47 * bool drivetype(const char *fname, char *dt, int dtlen);
50 #if defined (HAVE_WIN32)
53 bool drivetype(const char *fname, char *dt, int dtlen)
58 /* Copy Drive Letter, colon, and backslash to rootpath */
59 bstrncpy(rootpath, fname, 3);
62 type = GetDriveType(rootpath);
65 case DRIVE_REMOVABLE: bstrncpy(dt, "removable", dtlen); return true;
66 case DRIVE_FIXED: bstrncpy(dt, "fixed", dtlen); return true;
67 case DRIVE_REMOTE: bstrncpy(dt, "remote", dtlen); return true;
68 case DRIVE_CDROM: bstrncpy(dt, "cdrom", dtlen); return true;
69 case DRIVE_RAMDISK: bstrncpy(dt, "ramdisk", dtlen); return true;
71 case DRIVE_NO_ROOT_DIR:
78 #else /* No recognised OS */
80 bool drivetype(const char *fname, char *dt, int dtlen)
82 Dmsg0(10, "!!! drivetype() not implemented for this OS. !!!\n");
84 Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n",
94 int main(int argc, char **argv)
101 p = (argc < 1) ? "drivetype" : argv[0];
102 printf("usage:\t%s path ...\n"
103 "\t%s prints the drive type and pathname of the paths.\n",
108 if (!drivetype(*argv, dt, sizeof(dt))) {
109 status = EXIT_FAILURE;
111 printf("%s\t%s\n", dt, *argv);