| 1 |
/* |
| 2 |
* Copyright (c) 2024 Frederick H. G. Wright II <[email protected]> |
| 3 |
* |
| 4 |
* Permission to use, copy, modify, and distribute this software for any |
| 5 |
* purpose with or without fee is hereby granted, provided that the above |
| 6 |
* copyright notice and this permission notice appear in all copies. |
| 7 |
* |
| 8 |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 |
*/ |
| 16 |
|
| 17 |
/* |
| 18 |
* Earlier versions of legacy-support needed wrappers around several OS |
| 19 |
* calls related to directories, in order to implement fdopendir(). That |
| 20 |
* is no longer the case, but existing dependents still reference those |
| 21 |
* wrapper calls. For compatibility, we continue to provide those functions, |
| 22 |
* but just as transparent wrappers around the OS calls. |
| 23 |
* |
| 24 |
* These wrappers can eventually be removed once all dependents have been |
| 25 |
* rebuilt with the current headers. But since there would be significant |
| 26 |
* work in determining when this is the case, and since they only add 752 |
| 27 |
* bytes to the library size, they should probably be left in place for a |
| 28 |
* long time. |
| 29 |
* |
| 30 |
* This is only relevant for OS versions where our fdopendir() is needed, |
| 31 |
* hence the conditional (which is the same conditional as was used for |
| 32 |
* the earlier implementations). |
| 33 |
*/ |
| 34 |
|
| 35 |
/* MP support header */ |
| 36 |
#include "MacportsLegacySupport.h" |
| 37 |
#if __MP_LEGACY_SUPPORT_FDOPENDIR__ |
| 38 |
|
| 39 |
#include "dirfuncs_compat.h" |
| 40 |
|
| 41 |
DIR * |
| 42 |
__mpls_opendir(const char *filename) { |
| 43 |
return opendir(filename); |
| 44 |
} |
| 45 |
|
| 46 |
struct dirent * |
| 47 |
__mpls_readdir(DIR *dirp) { |
| 48 |
return readdir(dirp); |
| 49 |
} |
| 50 |
|
| 51 |
int |
| 52 |
__mpls_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { |
| 53 |
return readdir_r(dirp, entry, result); |
| 54 |
} |
| 55 |
|
| 56 |
long |
| 57 |
__mpls_telldir(DIR *dirp) { |
| 58 |
return telldir(dirp); |
| 59 |
} |
| 60 |
|
| 61 |
void |
| 62 |
__mpls_seekdir(DIR *dirp, long loc) { |
| 63 |
seekdir(dirp, loc); |
| 64 |
} |
| 65 |
|
| 66 |
void |
| 67 |
__mpls_rewinddir(DIR *dirp) { |
| 68 |
rewinddir(dirp); |
| 69 |
} |
| 70 |
|
| 71 |
int |
| 72 |
__mpls_closedir(DIR *dirp) { |
| 73 |
return closedir(dirp); |
| 74 |
} |
| 75 |
|
| 76 |
int |
| 77 |
__mpls_dirfd(DIR *dirp) { |
| 78 |
return dirfd(dirp); |
| 79 |
} |
| 80 |
|
| 81 |
#endif /* __MP_LEGACY_SUPPORT_FDOPENDIR__ */ |