Welcome to mirror list, hosted at ThFree Co, Russian Federation.

path.sgml « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 26c3ea34ebf6ae183cf975270c39dd8d9456d5ea (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<sect1 id="func-cygwin-conv-path">
<title>cygwin_conv_path</title>

<funcsynopsis><funcprototype>
<funcdef>extern "C" ssize_t
<function>cygwin_conv_path</function></funcdef>
<paramdef>cygwin_conv_path_t <parameter>what</parameter></paramdef>
<paramdef>const void * <parameter>from</parameter></paramdef>
<paramdef>void * <parameter>to</parameter></paramdef>
<paramdef>size_t <parameter>size</parameter></paramdef>
</funcprototype></funcsynopsis>

<para>Use this function to convert POSIX paths in
<parameter>from</parameter> to Win32 paths in <parameter>to</parameter>
or, vice versa, Win32 paths in <parameter>from</parameter> to POSIX paths
in <parameter>to</parameter>.  <parameter>what</parameter>
defines the direction of this conversion and can be any of the below
values.</para>

<programlisting>
  CCP_POSIX_TO_WIN_A      /* from is char *posix, to is char *win32       */
  CCP_POSIX_TO_WIN_W,     /* from is char *posix, to is wchar_t *win32    */
  CCP_WIN_A_TO_POSIX,     /* from is char *win32, to is char *posix       */
  CCP_WIN_W_TO_POSIX,     /* from is wchar_t *win32, to is char *posix    */
</programlisting>

<para>You can additionally or the following values to
<parameter>what</parameter>, to define whether you want the resulting
path in <parameter>to</parameter> to be absolute or if you want to keep
relative paths in relative notation.  Creating absolute paths is the
default.</para>

<programlisting>
  CCP_ABSOLUTE = 0,       /* Request absolute path (default).             */
  CCP_RELATIVE = 0x100    /* Request to keep path relative.               */
</programlisting>

<para><parameter>size</parameter> is the size of the buffer pointed to
by <parameter>to</parameter> in bytes.  If <parameter>size</parameter>
is 0, <function>cygwin_conv_path</function> just returns the required
buffer size in bytes.  Otherwise, it returns 0 on success, or -1 on
error and errno is set to one of the below values.</para>

<programlisting>
    EINVAL        what has an invalid value.
    EFAULT        from or to point into nirvana.
    ENAMETOOLONG  the resulting path is longer than 32K, or, in case
                  of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.
    ENOSPC        size is less than required for the conversion.
</programlisting>

<example>
<title>Example use of cygwin_conv_path</title>
<programlisting>
<![CDATA[
#include <sys/cygwin.h>

/* Conversion from incoming Win32 path given as wchar_t *win32 to POSIX path.
   If incoming path is a relative path, stick to it.  First ask how big
   the output buffer has to be and allocate space dynamically. */
ssize_t size;
char *posix;
size = cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32, NULL, 0);
if (size < 0)
  perror ("cygwin_conv_path");
else
  {
    posix = (char *) malloc (size);
    if (cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32,
                          posix, size))
      perror ("cygwin_conv_path");
  }
]]>
</programlisting>
</example>

</sect1>

<sect1 id="func-cygwin-conv-path-list">
<title>cygwin_conv_path_list</title>

<funcsynopsis><funcprototype>
<funcdef>extern "C" ssize_t
<function>cygwin_conv_path_list</function></funcdef>
<paramdef>cygwin_conv_path_t <parameter>what</parameter></paramdef>
<paramdef>const void * <parameter>from</parameter></paramdef>
<paramdef>void * <parameter>to</parameter></paramdef>
<paramdef>size_t <parameter>size</parameter></paramdef>
</funcprototype></funcsynopsis>

<para>This is the same as <function>cygwin_conv_path</function>, but the
input is treated as a path list in $PATH or %PATH% notation.</para>
<para>If <parameter>what</parameter> is CCP_POSIX_TO_WIN_A or
CCP_POSIX_TO_WIN_W, given a POSIX $PATH-style string (i.e. /foo:/bar)
convert it to the equivalent Win32 %PATH%-style string (i.e. d:\;e:\bar).</para>
<para>If <parameter>what</parameter> is CCP_WIN_A_TO_POSIX or
CCP_WIN_W_TO_POSIX, given a Win32 %PATH%-style string (i.e. d:\;e:\bar)
convert it to the equivalent POSIX $PATH-style string (i.e. /foo:/bar).</para>
<para><parameter>size</parameter> is the size of the buffer pointed to by
<parameter>to</parameter> in bytes.</para>

<para>See also <link linkend="func-cygwin-conv-path">cygwin_conv_path</link></para>

</sect1>

<sect1 id="func-cygwin-create-path">
<title>cygwin_create_path</title>

<funcsynopsis><funcprototype>
<funcdef>extern "C" void *
<function>cygwin_create_path</function></funcdef>
<paramdef>cygwin_conv_path_t <parameter>what</parameter></paramdef>
<paramdef>const void * <parameter>from</parameter></paramdef>
</funcprototype></funcsynopsis>

<para>This is equivalent to the <function>cygwin_conv_path</function>, except
that <function>cygwin_create_path</function> does not take a buffer pointer
for the result of the conversion as input.  Rather it allocates the buffer
itself using <function>malloc</function>(3) and returns a pointer to this
buffer.  In case of error it returns NULL and sets errno to one of the
values defined for <function>cygwin_conv_path</function>.  Additionally
errno can be set to the below value.</para>

<programlisting>
    ENOMEM        Insufficient memory was available.
</programlisting>

<para>When you don't need the returned buffer anymore, use
<function>free</function>(3) to deallocate it.</para>

<para>See also <link linkend="func-cygwin-conv-path">cygwin_conv_path</link></para>

</sect1>

<sect1 id="func-cygwin-posix-path-list-p">
<title>cygwin_posix_path_list_p</title>

<funcsynopsis><funcprototype>
<funcdef>extern "C" int
<function>cygwin_posix_path_list_p</function></funcdef>
<paramdef>const char *<parameter>path</parameter></paramdef>
</funcprototype></funcsynopsis>

<para>This function tells you if the supplied
<parameter>path</parameter> is a POSIX-style path (i.e. posix names,
forward slashes, colon delimiters) or a Win32-style path (drive
letters, reverse slashes, semicolon delimiters.  The return value is
true if the path is a POSIX path.  Note that "_p" means "predicate", a
lisp term meaning that the function tells you something about the
parameter.</para>

</sect1>

<sect1 id="func-cygwin-split-path">
<title>cygwin_split_path</title>

<funcsynopsis><funcprototype>
<funcdef>extern "C" void
<function>cygwin_split_path</function>
</funcdef>
<paramdef>const char * <parameter>path</parameter></paramdef>
<paramdef>char * <parameter>dir</parameter></paramdef>
<paramdef>char * <parameter>file</parameter></paramdef>
</funcprototype></funcsynopsis>

<para>Split a path into the directory and the file portions.  Both
<parameter>dir</parameter> and <parameter>file</parameter> are
expected to point to buffers of sufficient size.  </para>

<example>
<title>Example use of cygwin_split_path</title>
<programlisting>
char dir[200], file[100];
cygwin_split_path("c:/foo/bar.c", dir, file);
printf("dir=%s, file=%s\n", dir, file);
</programlisting>
</example>
</sect1>