annotate src/os_mac.c @ 436:a1c5a6cb2675 v7.0112

updated for version 7.0112
author vimboss
date Thu, 21 Jul 2005 21:11:17 +0000
parents 3da34f87c760
children d0d15b184c56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * os_mac.c -- code for the MacOS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * This file is mainly based on os_unix.c.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #if defined(__MRC__) || defined(__SC__) /* for Apple MPW Compilers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #include "StandardFile.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 * Implements the corresponding unix function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 stat(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 char *p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 struct stat *p_st)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 TODO: Use functions which fill the FileParam struct (Files.h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 and copy these contents to our self-defined stat struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 * change the current working directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 mch_chdir(char *p_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #if defined(__MRC__) || defined(__SC__) /* for Apple MPW Compilers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 return chdir(p_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 * Recursively build up a list of files in "gap" matching the first wildcard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 * in `path'. Called by mch_expandpath().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 * "path" has backslashes before chars that are not to be expanded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 mac_expandpath(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 garray_T *gap,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 char_u *path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 int flags, /* EW_* flags */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 short start_at,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 short as_full)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 * TODO:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 * +Get Volumes (when looking for files in current dir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 * +Make it work when working dir not on select volume
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 * +Cleanup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 short index = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 OSErr gErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 char_u dirname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 char_u cfilename[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 long dirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 char_u *new_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 CInfoPBRec gMyCPB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 HParamBlockRec gMyHPBlock;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 FSSpec usedDir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 char_u *p, *s, *e, dany;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 int start_len, c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 char_u *pat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 start_len = gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 buf = alloc(STRLEN(path) + BASENAMELEN + 5);/* make room for file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 * Find the first part in the path name that contains a wildcard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 * Copy it into buf, including the preceding characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 p = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 s = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 e = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 STRNCPY(buf, path, start_at);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 p += start_at;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 path += start_at;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 while (*path)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 if (*path == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 if (e)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 s = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 /* should use WILCARDLIST but what about ` */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 /* if (vim_strchr((char_u *)"*?[{~$", *path) != NULL)*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 else if (vim_strchr((char_u *)WILDCHAR_LIST, *path) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 e = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 int len = (*mb_ptr2len_check)(path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 STRNCPY(p, path, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 p += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 path += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 *p++ = *path++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 e = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 /* now we have one wildcard component between s and e */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 *e = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 dany = *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 *s = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 backslash_halve(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 *s = dany;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 /* convert the file pattern to a regexp pattern */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 pat = file_pat_to_reg_pat(s, e, NULL, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 if (pat == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 /* compile the regexp into a program */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 regmatch.rm_ic = FALSE; /* Don't ever ignore case */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 vim_free(pat);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 if (regmatch.regprog == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 /* open the directory for scanning */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 c = *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 *s = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 if (*buf == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 as_full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 (void) mch_dirname (&dirname[1], 254);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 dirname[0] = STRLEN(&dirname[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 if (*buf == ':') /* relative path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 (void)mch_dirname(&dirname[1], 254);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 new_name = concat_fnames(&dirname[1], buf+1, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 STRCPY(&dirname[1], new_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 dirname[0] = STRLEN(new_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 vim_free(new_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 STRCPY(&dirname[1], buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 backslash_halve(&dirname[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 dirname[0] = STRLEN(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 *s = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 FSMakeFSSpec (0, 0, dirname, &usedDir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 gMyCPB.dirInfo.ioNamePtr = dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 gMyCPB.dirInfo.ioVRefNum = usedDir.vRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 gMyCPB.dirInfo.ioFDirIndex = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 gMyCPB.dirInfo.ioDrDirID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 gErr = PBGetCatInfo(&gMyCPB, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 gMyCPB.dirInfo.ioCompletion = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 dirID = gMyCPB.dirInfo.ioDrDirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 gMyCPB.hFileInfo.ioFDirIndex = index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 gMyCPB.hFileInfo.ioDirID = dirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 gErr = PBGetCatInfo(&gMyCPB,false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 if (gErr == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 {
416
3da34f87c760 updated for version 7.0109
vimboss
parents: 272
diff changeset
214 vim_strncpy(cfilename, &dirname[1], dirname[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 if (vim_regexec(&regmatch, cfilename, (colnr_T)0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 if (s[-1] != ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 /* TODO: need to copy with cleaned name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 STRCPY(s+1, cfilename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 s[0] = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 { /* TODO: need to copy with cleeaned name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 STRCPY(s, cfilename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 start_at = STRLEN(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 STRCAT(buf, path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 if (mch_has_exp_wildcard(path)) /* handle more wildcards */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 (void)mac_expandpath(gap, buf, flags, start_at, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 #ifdef DONT_ADD_PATHSEP_TO_DIR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 if ((gMyCPB.hFileInfo.ioFlAttrib & ioDirMask) !=0 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 STRCAT(buf, PATHSEPSTR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 addfile(gap, buf, flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 if ((gMyCPB.hFileInfo.ioFlAttrib & ioDirMask) !=0 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 index++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 while (gErr == noErr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 if (as_full)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 index = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 gMyHPBlock.volumeParam.ioNamePtr = (char_u *) dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 gMyHPBlock.volumeParam.ioVRefNum =0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 gMyHPBlock.volumeParam.ioVolIndex = index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 gErr = PBHGetVInfo (&gMyHPBlock,false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 if (gErr == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 {
416
3da34f87c760 updated for version 7.0109
vimboss
parents: 272
diff changeset
263 vim_strncpy(cfilename, &dirname[1], dirname[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 if (vim_regexec(&regmatch, cfilename, (colnr_T)0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 STRCPY(s, cfilename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 STRCAT(buf, path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 if (mch_has_exp_wildcard(path)) /* handle more wildcards */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 (void)mac_expandpath(gap, s, flags, 0, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 #ifdef DONT_ADD_PATHSEP_TO_DIR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 /* if ((gMyCPB.hFileInfo.ioFlAttrib & ioDirMask) !=0 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 */ STRCAT(buf, PATHSEPSTR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 addfile(gap, s, flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 STRCAT(cfilename, PATHSEPSTR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 addfile (gap, cfilename, flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 index++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 while (gErr == noErr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 vim_free(regmatch.regprog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 return gap->ga_len - start_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 pstrcmp(a, b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 const void *a, *b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 {
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 15
diff changeset
300 return (pathcmp(*(char **)a, *(char **)b, -1));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 unix_expandpath(gap, path, wildoff, flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 garray_T *gap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 char_u *path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 int wildoff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 int flags; /* EW_* flags */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 char_u *path_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 char_u *p, *s, *e;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 int start_len, c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 char_u *pat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 DIR *dirp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 struct dirent *dp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 int starts_with_dot;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 int matches;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 start_len = gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 buf = alloc(STRLEN(path) + BASENAMELEN + 5);/* make room for file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 * Find the first part in the path name that contains a wildcard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 * Copy it into buf, including the preceding characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 p = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 s = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 e = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 path_end = path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 while (*path_end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 /* May ignore a wildcard that has a backslash before it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 if (path_end >= path + wildoff && rem_backslash(path_end))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 *p++ = *path_end++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 else if (*path_end == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 if (e != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 s = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 else if (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 e = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 len = (*mb_ptr2len_check)(path_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 STRNCPY(p, path_end, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 p += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 path_end += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 *p++ = *path_end++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 e = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 *e = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 /* now we have one wildcard component between s and e */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 /* Remove backslashes between "wildoff" and the start of the wildcard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 * component. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 for (p = buf + wildoff; p < s; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 if (rem_backslash(p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 STRCPY(p, p + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 --e;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 --s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 /* convert the file pattern to a regexp pattern */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 starts_with_dot = (*s == '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 pat = file_pat_to_reg_pat(s, e, NULL, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 if (pat == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 /* compile the regexp into a program */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 #ifdef MACOS_X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 /* We want to behave like Terminal.app */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 regmatch.rm_ic = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 regmatch.rm_ic = FALSE; /* Don't ever ignore case */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 vim_free(pat);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 if (regmatch.regprog == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 /* open the directory for scanning */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 c = *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 *s = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 dirp = opendir(*buf == NUL ? "." : (char *)buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 *s = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 /* Find all matching entries */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 if (dirp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 dp = readdir(dirp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 if (dp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 if ((dp->d_name[0] != '.' || starts_with_dot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 && vim_regexec(&regmatch, (char_u *)dp->d_name, (colnr_T)0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 STRCPY(s, dp->d_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 len = STRLEN(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 STRCPY(buf + len, path_end);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 if (mch_has_exp_wildcard(path_end)) /* handle more wildcards */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 /* need to expand another component of the path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 /* remove backslashes for the remaining components only */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 (void)unix_expandpath(gap, buf, len + 1, flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 /* no more wildcards, check if there is a match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 /* remove backslashes for the remaining components only */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 if (*path_end)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 backslash_halve(buf + len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 if (mch_getperm(buf) >= 0) /* add existing file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 addfile(gap, buf, flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 closedir(dirp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 vim_free(regmatch.regprog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 matches = gap->ga_len - start_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 if (matches)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 qsort(((char_u **)gap->ga_data) + start_len, matches,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 sizeof(char_u *), pstrcmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 return matches;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 * Recursively build up a list of files in "gap" matching the first wildcard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 * in `path'. Called by expand_wildcards().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 * "pat" has backslashes before chars that are not to be expanded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 mch_expandpath(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 garray_T *gap,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 char_u *path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 int flags) /* EW_* flags */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 return unix_expandpath(gap, path, 0, flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 char_u first = *path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 short scan_volume;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 slash_n_colon_adjust(path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 scan_volume = (first != *path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 return mac_expandpath(gap, path, flags, 0, scan_volume);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 fname_case(name, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 int len; /* buffer size, ignored here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 * TODO: get the real casing for the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 * make it called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 * with USE_FNAME_CASE & USE_LONG_FNAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 * CASE_INSENSITIVE_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 * within setfname, fix_fname, do_ecmd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 FSRef refFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 UInt32 pathSize = STRLEN(name) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 char_u *path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 Boolean isDirectory;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 path = alloc(pathSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 if (path == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 status = FSPathMakeRef((UInt8 *)name, &refFile, &isDirectory);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 if (status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 status = FSRefMakePath(&refFile, (UInt8 *)path, pathSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 if (status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 /* Paranoid: Update the name if only the casing differ.*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 if (STRICMP(name, path) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 STRCPY(name, path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 static char_u *oldtitle = (char_u *) "gVim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 * check for an "interrupt signal": CTRL-break or CTRL-C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 mch_breakcheck()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 * TODO: Scan event for a CTRL-C or COMMAND-. and do: got_int=TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 * or only go proccess event?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 * or do nothing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 EventRecord theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
528 if (EventAvail(keyDownMask, &theEvent))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 if ((theEvent.message & charCodeMask) == Ctrl_C && ctrl_c_interrupts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 short i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 Boolean found = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 EventRecord theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 while ((i < 10) && (!found))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 found = EventAvail (keyDownMask, &theEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 if (found)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 if ((theEvent.modifiers & controlKey) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 found = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 if ((theEvent.what == keyDown))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 found = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 if ((theEvent.message & charCodeMask) == Ctrl_C)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 found = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 i++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 * Return amount of memory currently available.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 long_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 mch_avail_mem(special)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 int special;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 * TODO: Use MaxBlock, FreeMeM, PurgeSpace, MaxBlockSys FAQ-266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 * figure out what the special is for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 * FreeMem -> returns all avail memory is application heap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 * MaxBlock -> returns the biggest contigeous block in application heap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 * PurgeSpace ->
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 return MaxBlock();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 mch_delay(msec, ignoreinput)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 long msec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 int ignoreinput;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 #if (defined(__MWERKS__) && __MWERKS__ >= 0x2000) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 || defined(__MRC__) || defined(__SC__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 unsigned
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 long finalTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 if (ignoreinput)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 Delay (60*msec/1000, &finalTick);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 /* even thougth we should call gui stuff from here
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 it the simplest way to be safe */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 gui_mch_wait_for_chars(msec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 mch_init()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 * TODO: Verify if needed, or override later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 Columns = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 Rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 * Check_win checks whether we have an interactive stdout.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 mch_check_win(argc, argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 int argc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 char **argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 * TODO: Maybe to be remove through NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 * Return TRUE if the input comes from a terminal, FALSE otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 mch_input_isatty()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 * TODO: Maybe to be remove through NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 * Set the window title and icon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 * (The icon is not taken care of).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 mch_settitle(title, icon)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 char_u *title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 char_u *icon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 gui_mch_settitle(title, icon);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 * Restore the window/icon title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 * which is one of:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 * 1 Just restore title
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 * 2 Just restore icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * 3 Restore title and icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 * but don't care about the icon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 mch_restore_title(which)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 int which;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 mch_settitle((which & 1) ? oldtitle : NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 * Insert user name in s[len].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 * Return OK if a name found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 mch_get_user_name(s, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 #if !(defined(__MRC__) || defined(__SC__)) /* No solution yet */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 * TODO: clean up and try getlogin ()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 #if defined(HAVE_PWD_H) && defined(HAVE_GETPWUID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 struct passwd *pw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 uid_t uid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 uid = getuid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 #if defined(HAVE_PWD_H) && defined(HAVE_GETPWUID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 if ((pw = getpwuid(uid)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 && pw->pw_name != NULL && *(pw->pw_name) != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 {
416
3da34f87c760 updated for version 7.0109
vimboss
parents: 272
diff changeset
682 vim_strncpy(s, pw->pw_name, len - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 sprintf((char *)s, "%d", (int)uid); /* assumes s is long enough */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 return FAIL; /* a number is not a name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 * Copy host name into s[len].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 mch_get_host_name(s, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 #if defined(__MRC__) || defined(__SC__) || defined(__APPLE_CC__)
416
3da34f87c760 updated for version 7.0109
vimboss
parents: 272
diff changeset
700 vim_strncpy(s, "Mac", len - 1); /* TODO: use Gestalt information */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 struct utsname vutsname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 if (uname(&vutsname) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 *s = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 else
416
3da34f87c760 updated for version 7.0109
vimboss
parents: 272
diff changeset
707 vim_strncpy(s, vutsname.nodename, len - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 * return process ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 long
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 mch_get_pid()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 return (long)getpid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 * Get name of current directory into buffer 'buf' of length 'len' bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 * Return OK for success, FAIL for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 mch_dirname(buf, len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 #if defined(__MRC__) || defined(__SC__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 return FAIL; /* No solution yet */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 /* The last : is already put by getcwd */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 if (getcwd((char *)buf, len) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 STRCPY(buf, strerror(errno));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 # ifndef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 else if (*buf != NUL && buf[STRLEN(buf) - 1] == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 buf[STRLEN(buf) - 1] = NUL; /* remove trailing ':' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 slash_to_colon(p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 for ( ; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 if (*p == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 *p = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 slash_to_colon_save (p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 char_u *res;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 res = vim_strsave(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 if (res == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 slash_to_colon(res);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 return res;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 slash_n_colon_adjust (buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 * TODO: Make it faster
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 #ifndef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 char_u temp[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 char_u *first_colon = vim_strchr(buf, ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 char_u *first_slash = vim_strchr(buf, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 int full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 char_u *scanning;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 char_u *filling;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 char_u last_copied = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 if (*buf == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 return ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 if ((first_colon == NULL) && (first_slash == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 full = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 if ((first_slash == NULL) && (first_colon != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 if ((first_colon == NULL) && (first_slash != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 full = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 if ((first_slash < first_colon) && (first_slash != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 full = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 if ((first_colon < first_slash) && (first_colon != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 if (first_slash == buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 if (first_colon == buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 full = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 scanning = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 filling = temp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 while (*scanning != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 if (*scanning == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 if ((scanning[1] != '/') && (scanning[-1] != ':'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 *filling++ = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 scanning++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 scanning++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 else if (*scanning == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 if ((scanning[1] == NUL) || scanning[1] == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 if (scanning[1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 scanning += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 scanning += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 else if (scanning[1] == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 if ((scanning[2] == NUL) || scanning[2] == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 *filling++ = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 if (scanning[2] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 scanning +=2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 scanning += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 *filling++ = *scanning++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 *filling++ = *scanning++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 *filling++ = *scanning++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 *filling = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 filling = temp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 if (!full)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 if (buf[0] != ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 buf[0] = ':';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 buf[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 buf[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 buf[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 if (filling[0] == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 filling++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 STRCAT (buf, filling);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 * Get absolute filename into buffer 'buf' of length 'len' bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 * return FAIL for failure, OK for success
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 mch_FullName(fname, buf, len, force)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 char_u *fname, *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 int force; /* also expand when already absolute path name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 * TODO: Find what TODO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 char_u olddir[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 char_u newdir[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 char_u c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 int retval = OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 if (force || !mch_isFullName(fname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 * Forced or not an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 * If the file name has a path, change to that directory for a moment,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 * and then do the getwd() (and get back to where we were).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 * This will get the correct path name with "../" things.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 if ((p = vim_strrchr(fname, ':')) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 if (mch_dirname(olddir, MAXPATHL) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 p = NULL; /* can't get current dir: don't chdir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 c = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 if (mch_chdir((char *)fname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 fname = p; /* + 1;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 *p = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 if (mch_dirname(buf, len) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 *newdir = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 l = STRLEN(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 if (STRCMP(fname, ".") != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 if (l > 0 && buf[l - 1] != '/' && *fname != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 STRCAT(buf, "/");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 if (l > 0 && buf[l - 1] != ':' && *fname != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 STRCAT(buf, ":");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 mch_chdir((char *)olddir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 if (STRCMP(fname, ".") != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 STRCAT(buf, fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 {
416
3da34f87c760 updated for version 7.0109
vimboss
parents: 272
diff changeset
949 vim_strncpy(buf, fname, len - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 slash_n_colon_adjust(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 * Return TRUE if "fname" does not depend on the current directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 mch_isFullName(fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 return ((fname[0] == '/') || (fname[0] == '~'));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 * TODO: Make sure fname is always of mac still
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 * i.e: passed throught slash_n_colon_adjust
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 char_u *first_colon = vim_strchr(fname, ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 char_u *first_slash = vim_strchr(fname, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 if (first_colon == fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 if (first_slash == fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 if ((first_colon < first_slash) && (first_colon != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 if ((first_slash < first_colon) && (first_slash != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 if ((first_colon == NULL) && (first_slash != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 if ((first_slash == NULL) && (first_colon != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 if ((first_colon == NULL) && (first_slash == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 * Replace all slashes by colons.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 slash_adjust(p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 #ifndef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 * TODO: keep escaped '/'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 while (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 if (*p == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 *p = ':';
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 15
diff changeset
1007 mb_ptr_adv(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 * Get file permissions for 'name'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 * Returns -1 when it doesn't exist.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 long
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 mch_getperm(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 * TODO: Maybe use AppleShare info??
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 * Use locked for non writable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 struct stat statb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 if (stat((char *)name, &statb))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 return statb.st_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 * set file permission for 'name' to 'perm'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 * return FAIL for failure, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 mch_setperm(name, perm)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 long perm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 * TODO: Maybe use AppleShare info??
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 * Use locked for non writable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 return (OK);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 * Set hidden flag for "name".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 mch_hide(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 * TODO: Hide the file throught FileManager FAQ 8-34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 * *name is mac style start with : for relative
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 * return TRUE if "name" is a directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 * return FALSE if "name" is not a directory
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 * return FALSE for error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 mch_isdir(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 * TODO: Find out by FileManager calls ...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 struct stat statb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 #if defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 /* For some reason the name is sometimes empty,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 * (such as for a not yet named file). An empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 * filename is interpreted by the MacOS version
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 * of stat (at least under Codewarrior) as the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 * current directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 /* AK 20020413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 * This is required for Carbon but breaks the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 * explorer plugin in Classic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 if (name[0] == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 if (stat((char *)name, &statb))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 #if defined(__MRC__) || defined(__SC__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 return FALSE; /* definitely TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 return ((statb.st_mode & S_IFMT) == S_IFDIR ? TRUE : FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 #if defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 * Return 1 if "name" can be executed, 0 if not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 * Return -1 if unknown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 mch_can_exe(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 * Check what "name" is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 * NODE_NORMAL: file or directory (or doesn't exist)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 * NODE_WRITABLE: writable device, socket, fifo, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 * NODE_OTHER: non-writable things
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 mch_nodetype(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 return NODE_NORMAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 mch_early_init()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 mch_exit(r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 int r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 display_errors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 ml_close_all(TRUE); /* remove all memfiles */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 exit(r);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 mch_settmode(tmode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 int tmode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 * TODO: remove the needs of it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 #ifdef FEAT_MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 * set mouse clicks on or off (only works for xterms)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 mch_setmouse(on)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 int on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 * TODO: remove the needs of it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 * set screen mode, always fails.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 mch_screenmode(arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 char_u *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 EMSG(_(e_screenmode));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 mch_call_shell(cmd, options)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 char_u *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 int options; /* SHELL_*, see vim.h */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 * TODO: find a shell or pseudo-shell to call
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 * for some simple useful command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 return (-1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 * Return TRUE if "p" contains a wildcard that can be expanded by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 * mch_expandpath().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 mch_has_exp_wildcard(p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 {
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 15
diff changeset
1201 for ( ; *p; mb_ptr_adv(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 if (*p == '\\' && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 else if (vim_strchr((char_u *)WILDCHAR_LIST, *p) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 mch_has_wildcard(p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 if (*p == '~' && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 return mch_has_exp_wildcard(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 * This procedure duplicate a file, it is used in order to keep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 * the footprint of the previous file, when some info can be easily
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 * restored with set_perm().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 * Return -1 for failure, 0 for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 mch_copy_file(from, to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 char_u *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 char_u *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 char_u from_str[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 char_u to_str[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 char_u to_name[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 HParamBlockRec paramBlock;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 char_u *char_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 * Convert C string to Pascal string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 char_ptr = from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 len = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 for (; (*char_ptr != 0) && (len < 255); len++, char_ptr++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 from_str[len] = *char_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 from_str[0] = len-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 char_ptr = to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 len = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 for (; (*char_ptr != 0) && (len < 255); len++, char_ptr++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 to_str[len] = *char_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 to_str[0] = len-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 paramBlock.copyParam.ioCompletion = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 paramBlock.copyParam.ioNamePtr = from_str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 /* paramBlock.copyParam.ioVRefnum = overided by ioFilename; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 /* paramBlock.copyParam.ioDirI = overided by ioFilename; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 paramBlock.copyParam.ioNewName = to_str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 paramBlock.copyParam.ioCopyName = to_name; /* NIL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 /* paramBlock.copyParam.ioDstVRefNum = overided by ioNewName; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 /* paramBlock.copyParam.ioNewDirID = overided by ioNewName; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 * First delete the "to" file, this is required on some systems to make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 * the rename() work, on other systems it makes sure that we don't have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 * two files when the rename() fails.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 mch_remove(to);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 * First try a normal rename, return if it works.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 (void) PBHCopyFile(&paramBlock, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 mch_copy_file_attribute(from, to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 char_u *from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 char_u *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 {
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1291 FSSpec frFSSpec;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1292 FSSpec toFSSpec;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1293 FInfo fndrInfo;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1294 Str255 name;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1295 ResType type;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1296 ResType sink;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1297 Handle resource;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1298 short idxTypes;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1299 short nbTypes;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1300 short idxResources;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1301 short nbResources;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1302 short ID;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1303 short frRFid;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1304 short toRFid;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1305 short attrs_orig;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1306 short attrs_copy;
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1307 short temp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 /* TODO: Handle error */
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1310 (void)GetFSSpecFromPath(from, &frFSSpec);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1311 (void)GetFSSpecFromPath(to , &toFSSpec);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 /* Copy resource fork */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 temp = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 frRFid = FSpOpenResFile (&frFSSpec, fsCurPerm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 if (frRFid != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 FSpCreateResFile(&toFSSpec, 'TEXT', UNKNOWN_CREATOR, 0);
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1322 toRFid = FSpOpenResFile(&toFSSpec, fsRdWrPerm);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1324 UseResFile(frRFid);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 nbTypes = Count1Types();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 for (idxTypes = 1; idxTypes <= nbTypes; idxTypes++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 {
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1330 Get1IndType(&type, idxTypes);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1331 nbResources = Count1Resources(type);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1333 for (idxResources = 1; idxResources <= nbResources; idxResources++)
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1334 {
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1335 attrs_orig = 0; /* in case GetRes fails */
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1336 attrs_copy = 0; /* in case GetRes fails */
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1337 resource = Get1IndResource(type, idxResources);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1338 GetResInfo(resource, &ID, &sink, name);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1339 HLock(resource);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1340 attrs_orig = GetResAttrs(resource);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1341 DetachResource(resource);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1344 UseResFile(toRFid);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1345 AddResource(resource, type, ID, name);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1346 attrs_copy = GetResAttrs(resource);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1347 attrs_copy = (attrs_copy & 0x2) | (attrs_orig & 0xFD);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1348 SetResAttrs(resource, attrs_copy);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1349 WriteResource(resource);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1350 UpdateResFile(toRFid);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1352 temp = GetResAttrs(resource);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1354 /*SetResAttrs (resource, 0);*/
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1355 HUnlock(resource);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1356 ReleaseResource(resource);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1357 UseResFile(frRFid);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 }
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1360 CloseResFile(toRFid);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1361 CloseResFile(frRFid);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1362 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 /* Copy Finder Info */
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1365 (void)FSpGetFInfo(&frFSSpec, &fndrInfo);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1366 (void)FSpSetFInfo(&toFSSpec, &fndrInfo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 return (temp == attrs_copy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 mch_has_resource_fork (file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 char_u *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 FSSpec fileFSSpec;
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1376 short fileRFid;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 /* TODO: Handle error */
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1379 (void)GetFSSpecFromPath(file, &fileFSSpec);
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1380 fileRFid = FSpOpenResFile(&fileFSSpec, fsCurPerm);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 if (fileRFid != -1)
15
631143ac4a01 updated for version 7.0007
vimboss
parents: 9
diff changeset
1382 CloseResFile(fileRFid);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 return (fileRFid != -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 mch_get_shellsize(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 /* never used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 mch_set_shellsize(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 /* never used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 * Rows and/or Columns has changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 mch_new_shellsize(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 /* never used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 * Those function were set as #define before, but in order
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 * to allow an easier us of os_unix.c for the MacOS X port,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 * they are change to procedure. Thec ompile whould optimize
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 * them out.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 mch_can_restore_title()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 mch_can_restore_icon()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 * If the machine has job control, use it to suspend the program,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 * otherwise fake it by starting a new shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 mch_suspend()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 /* TODO: get calle in #ifndef NO_CONSOLE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 gui_mch_iconify();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438