VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/path.h@ 90803

Last change on this file since 90803 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.8 KB
Line 
1/* $Id: path.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * IPRT - RTPath Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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 IPRT_INCLUDED_INTERNAL_path_h
28#define IPRT_INCLUDED_INTERNAL_path_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/cdefs.h>
34#include <iprt/param.h>
35
36RT_C_DECLS_BEGIN
37
38#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
39# define HAVE_UNC 1
40# define HAVE_DRIVE 1
41#endif
42
43/** The name of the environment variable that is used to override the default
44 * codeset used when talking to the file systems. This is only available on
45 * Mac OS X and UNIX systems. */
46#define RTPATH_CODESET_ENV_VAR "IPRT_PATH_CODESET"
47
48
49DECLHIDDEN(size_t) rtPathRootSpecLen(const char *pszPath);
50DECLHIDDEN(size_t) rtPathVolumeSpecLen(const char *pszPath);
51DECLHIDDEN(int) rtPathPosixRename(const char *pszSrc, const char *pszDst, unsigned fRename, RTFMODE fFileType);
52DECLHIDDEN(int) rtPathWin32MoveRename(const char *pszSrc, const char *pszDst, uint32_t fFlags, RTFMODE fFileType);
53
54
55/**
56 * Converts a path from IPRT to native representation.
57 *
58 * This may involve querying filesystems what codeset they speak and so forth.
59 *
60 * @returns IPRT status code.
61 * @param ppszNativePath Where to store the pointer to the native path.
62 * Free by calling rtPathFreeHost(). NULL on failure.
63 * Can be the same as pszPath.
64 * @param pszPath The path to convert.
65 * @param pszBasePath What pszPath is relative to. NULL if current
66 * directory.
67 *
68 * @remark This function is not available on hosts using something else than
69 * byte sequences as names (eg win32).
70 */
71int rtPathToNative(char const **ppszNativePath, const char *pszPath, const char *pszBasePath);
72
73/**
74 * Frees a native path returned by rtPathToNative() or rtPathToNativeEx().
75 *
76 * @param pszNativePath The host path to free. NULL allowed.
77 * @param pszPath The original path. This is for checking if
78 * rtPathToNative returned the pointer to the original.
79 *
80 * @remark This function is not available on hosts using something else than
81 * byte sequences as names (eg win32).
82 */
83void rtPathFreeNative(char const *pszNativePath, const char *pszPath);
84
85/**
86 * Converts a path from the native to the IPRT representation.
87 *
88 * @returns IPRT status code.
89 * @param ppszPath Where to store the pointer to the IPRT path.
90 * Free by calling rtPathFreeIprt(). NULL on failure.
91 * @param pszNativePath The native path to convert.
92 * @param pszBasePath What pszNativePath is relative to - in IPRT
93 * representation. NULL if current directory.
94 *
95 * @remark This function is not available on hosts using something else than
96 * byte sequences as names (eg win32).
97 */
98int rtPathFromNative(const char **ppszPath, const char *pszNativePath, const char *pszBasePath);
99
100/**
101 * Frees a path returned by rtPathFromNative or rtPathFromNativeEx.
102 *
103 * @param pszPath The returned path.
104 * @param pszNativePath The original path.
105 */
106void rtPathFreeIprt(const char *pszPath, const char *pszNativePath);
107
108/**
109 * Convert a path from the native representation to the IPRT one, using the
110 * specified path buffer.
111 *
112 * @returns VINF_SUCCESS, VERR_BUFFER_OVERFLOW, and recoding errors.
113 *
114 * @param pszPath The output buffer.
115 * @param cbPath The size of the output buffer.
116 * @param pszNativePath The path to convert.
117 * @param pszBasePath What pszNativePath is relative to - in IPRT
118 * representation. NULL if current directory.
119 */
120int rtPathFromNativeCopy(char *pszPath, size_t cbPath, const char *pszNativePath, const char *pszBasePath);
121
122/**
123 * Convert a path from the native representation to the IPRT one, allocating a
124 * string buffer for the result.
125 *
126 * @returns VINF_SUCCESS, VERR_NO_STR_MEMORY, and recoding errors.
127 *
128 * @param ppszPath Where to return the pointer to the IPRT path. Must
129 * be freed by calling RTStrFree.
130 * @param pszNativePath The path to convert.
131 * @param pszBasePath What pszNativePath is relative to - in IPRT
132 * representation. NULL if current directory.
133 */
134int rtPathFromNativeDup(char **ppszPath, const char *pszNativePath, const char *pszBasePath);
135
136
137#if defined(RT_OS_WINDOWS) && defined(IPRT_INCLUDED_fs_h) && defined(UNICODE_NULL)
138DECLHIDDEN(int) rtPathNtQueryInfoWorker(HANDLE hRootDir, struct _UNICODE_STRING *pNtName, PRTFSOBJINFO pObjInfo,
139 RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags, const char *pszPath);
140DECLHIDDEN(int) rtPathNtQueryInfoFromHandle(HANDLE hFile, void *pvBuf, size_t cbBuf, PRTFSOBJINFO pObjInfo,
141 RTFSOBJATTRADD enmAddAttr, const char *pszPath, ULONG uReparseTag);
142#endif
143
144
145RT_C_DECLS_END
146
147#endif /* !IPRT_INCLUDED_INTERNAL_path_h */
148
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette