[94dc7a]: src / win32 / winposix.c Maximize Restore History

Download this file

winposix.c    62 lines (54 with data), 2.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Copyright (C) 2005
* Written by Keith Marshall (keithmarshall@users.sourceforge.net)
*
* Provides:
* char* win32path_transform( const char* pathname );
*
* This function replaces all occurrences of the "\" character,
* in the specified Win32 "pathname", with the "/" character.
*
* int win32path_is_absolute( const char* pathname );
*
* This function determines if the specified Win32 "pathname"
* represents an absolute location in the Win32 file system.
* (Note that "pathname" is transformed in-situ, according to
* the algorithm employed by win32path_transform).
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY of any kind; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer
* to the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin St - Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "compat.h"
/* win32path_transform(): fix up Win32 path names, so that they
* conform to the POSIX convention of using "/" as the directory separator,
* (but leave "D:" as a drive designator, if it is present).
*/
char *win32path_transform (const char *pathname)
{
char *p = (char *)pathname;
if ( p )
do if (*p == '\\') *p = '/';
while (*p++);
return (char *) pathname;
}
/* win32path_is_absolute(): check if a specified Win32 path,
* which may, or may not have been transformed by win32path_transform(),
* represents an absolute reference to a file system location.
*/
int win32path_is_absolute (const char *pathname)
{
pathname = win32path_transform (pathname);
return (*pathname == '/') || ((pathname[1] == ':') && (pathname[2] == '/'));
}
/* $Source$: end of file */