1 | /* $Id: path.h 28903 2010-04-29 14:58:12Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - RTPath Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___internal_path_h
|
---|
28 | #define ___internal_path_h
|
---|
29 |
|
---|
30 | #include <iprt/cdefs.h>
|
---|
31 | #include <iprt/param.h>
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 | #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
36 | # define HAVE_UNC 1
|
---|
37 | # define HAVE_DRIVE 1
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | /** The name of the environment variable that is used to override the default
|
---|
41 | * codeset used when talking to the file systems. This is only available on
|
---|
42 | * Mac OS X and UNIX systems. */
|
---|
43 | #define RTPATH_CODESET_ENV_VAR "IPRT_PATH_CODESET"
|
---|
44 |
|
---|
45 |
|
---|
46 | DECLHIDDEN(size_t) rtPathRootSpecLen(const char *pszPath);
|
---|
47 | DECLHIDDEN(size_t) rtPathVolumeSpecLen(const char *pszPath);
|
---|
48 | DECLHIDDEN(int) rtPathPosixRename(const char *pszSrc, const char *pszDst, unsigned fRename, RTFMODE fFileType);
|
---|
49 | DECLHIDDEN(int) rtPathWin32MoveRename(const char *pszSrc, const char *pszDst, uint32_t fFlags, RTFMODE fFileType);
|
---|
50 |
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Converts a path from IPRT to native representation.
|
---|
54 | *
|
---|
55 | * This may involve querying filesystems what codeset they speak and so forth.
|
---|
56 | *
|
---|
57 | * @returns IPRT status code.
|
---|
58 | * @param ppszNativePath Where to store the pointer to the native path.
|
---|
59 | * Free by calling rtPathFreeHost(). NULL on failure.
|
---|
60 | * Can be the same as pszPath.
|
---|
61 | * @param pszPath The path to convert.
|
---|
62 | *
|
---|
63 | * @remark This function is not available on hosts using something else than
|
---|
64 | * byte seqences as names (eg win32).
|
---|
65 | */
|
---|
66 | int rtPathToNative(char **ppszNativePath, const char *pszPath);
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Converts a path from IPRT to native representation.
|
---|
70 | *
|
---|
71 | * This may involve querying filesystems what codeset they speak and so forth.
|
---|
72 | *
|
---|
73 | * @returns IPRT status code.
|
---|
74 | * @param ppszNativePath Where to store the pointer to the native path.
|
---|
75 | * Free by calling rtPathFreeHost(). NULL on failure.
|
---|
76 | * Can be the same as pszPath.
|
---|
77 | * @param pszPath The path to convert.
|
---|
78 | * @param pszBasePath What pszPath is relative to. If NULL the function
|
---|
79 | * behaves like rtPathToNative().
|
---|
80 | *
|
---|
81 | * @remark This function is not available on hosts using something else than
|
---|
82 | * byte seqences as names (eg win32).
|
---|
83 | */
|
---|
84 | int rtPathToNativeEx(char **ppszNativePath, const char *pszPath, const char *pszBasePath);
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Frees a native path returned by rtPathToNative() or rtPathToNativeEx().
|
---|
88 | *
|
---|
89 | * @param pszNativePath The host path to free. NULL allowed.
|
---|
90 | * @param pszPath The original path. This is for checking if
|
---|
91 | * rtPathToNative returned the pointer to the original.
|
---|
92 | *
|
---|
93 | * @remark This function is not available on hosts using something else than
|
---|
94 | * byte seqences as names (eg win32).
|
---|
95 | */
|
---|
96 | void rtPathFreeNative(char *pszNativePath, const char *pszPath);
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Converts a path from the native to the IPRT representation.
|
---|
100 | *
|
---|
101 | * @returns IPRT status code.
|
---|
102 | * @param ppszPath Where to store the pointer to the IPRT path.
|
---|
103 | * Free by calling RTStrFree(). NULL on failure.
|
---|
104 | * @param pszNativePath The native path to convert.
|
---|
105 | *
|
---|
106 | * @remark This function is not available on hosts using something else than
|
---|
107 | * byte seqences as names (eg win32).
|
---|
108 | */
|
---|
109 | int rtPathFromNative(char **ppszPath, const char *pszNativePath);
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * Converts a path from the native to the IPRT representation.
|
---|
113 | *
|
---|
114 | * @returns IPRT status code.
|
---|
115 | * @param ppszPath Where to store the pointer to the IPRT path.
|
---|
116 | * Free by calling RTStrFree(). NULL on failure.
|
---|
117 | * @param pszNativePath The native path to convert.
|
---|
118 | * @param pszBasePath What pszHostPath is relative to - in IPRT
|
---|
119 | * representation. If NULL the function behaves like
|
---|
120 | * rtPathFromNative().
|
---|
121 | *
|
---|
122 | * @remark This function is not available on hosts using something else than
|
---|
123 | * byte seqences as names (eg win32).
|
---|
124 | */
|
---|
125 | int rtPathFromNativeEx(char **ppszPath, const char *pszNativePath, const char *pszBasePath);
|
---|
126 |
|
---|
127 |
|
---|
128 | RT_C_DECLS_END
|
---|
129 |
|
---|
130 | #endif
|
---|
131 |
|
---|