MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / symdirget

Function symdirget

mysys/mf_pack.c:243–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241
242#ifdef USE_SYMDIR
243void symdirget(char *dir, my_bool *is_symdir)
244{
245 char buff[FN_REFLEN+1];
246 char *pos=strend(dir);
247 if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK))
248 {
249 File file;
250 size_t length;
251 char temp= *(--pos); /* May be "/" or "\" */
252 strmov(pos,".sym");
253 file= my_open(dir, O_RDONLY, MYF(0));
254 *pos++=temp; *pos=0; /* Restore old filename */
255 if (file >= 0)
256 {
257 if ((length= my_read(file, buff, sizeof(buff) - 1, MYF(0))) > 0)
258 {
259 for (pos= buff + length ;
260 pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ;
261 pos --);
262
263 /* Ensure that the symlink ends with the directory symbol */
264 if (pos == buff || pos[-1] != FN_LIBCHAR)
265 *pos++=FN_LIBCHAR;
266
267 strmake(dir,buff, (size_t) (pos-buff));
268
269 *is_symdir= TRUE;
270 }
271 my_close(file, MYF(0));
272 }
273 }
274}
275#endif /* USE_SYMDIR */
276
277

Callers 1

unpack_dirnameFunction · 0.85

Calls 7

strendFunction · 0.85
my_accessFunction · 0.85
strmovFunction · 0.85
my_openFunction · 0.85
my_readFunction · 0.85
strmakeFunction · 0.85
my_closeFunction · 0.85

Tested by

no test coverage detected