| 241 | |
| 242 | #ifdef USE_SYMDIR |
| 243 | void 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 | |