1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
|
/* Generated by Nim Compiler v2.2.0 */
#define NIM_INTBITS 64
#include "nimbase.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__9cCtUq5i0enQQmapg7J4F7g tyTuple__9cCtUq5i0enQQmapg7J4F7g;
typedef struct tyTuple__UV3llMMYFckfui8YMBuUZA tyTuple__UV3llMMYFckfui8YMBuUZA;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
typedef NU8 tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ;
struct tyTuple__9cCtUq5i0enQQmapg7J4F7g {
tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ Field0;
NIM_BOOL Field1;
};
struct tyTuple__UV3llMMYFckfui8YMBuUZA {
NimStringV2 Field0;
NimStringV2 Field1;
};
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0);
N_LIB_PRIVATE N_NIMCALL(NI32, osLastError__stdZoserrors_u122)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseOSError__stdZoserrors_u119)(NI32 errorCode_p0, NimStringV2 additionalInfo_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___stdZprivateZoscommon_u100)(tyTuple__UV3llMMYFckfui8YMBuUZA* x_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___system_u2597)(NimStringV2 dest_p0);
extern NIM_BOOL nimInErrorMode__system_u4274;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
void* T1_;
T1_ = (void*)0;
T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (&nimInErrorMode__system_u4274);
return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}BeforeRet_: ;
}
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0) {
NCSTRING result;
{
if (!(s_p0.len == ((NI)0))) goto LA3_;
result = "";
}
goto LA1_;
LA3_: ;
{
result = ((NCSTRING) ((*s_p0.p).data));
}
LA1_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosfileExists)(NimStringV2 filename_p0) {
NIM_BOOL result;
struct stat res;
NIM_BOOL T1_;
int T2_;
{ nimZeroMem((void*)(&res), sizeof(struct stat));
T1_ = (NIM_BOOL)0;
T2_ = (int)0;
T2_ = stat(nimToCStringConv(filename_p0), (&res));
T1_ = (((NI32)0) <= T2_);
if (!(T1_)) goto LA3_;
T1_ = S_ISREG(res.st_mode);
LA3_: ;
result = T1_;
goto BeforeRet_;
}BeforeRet_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(tyTuple__9cCtUq5i0enQQmapg7J4F7g, getSymlinkFileKind__stdZprivateZoscommon_u26)(NimStringV2 path_p0) {
tyTuple__9cCtUq5i0enQQmapg7J4F7g result;
struct stat s;
tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ colontmp_;
NIM_BOOL colontmp__2;
nimZeroMem((void*)(&s), sizeof(struct stat));
colontmp_ = ((tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ)1);
colontmp__2 = NIM_FALSE;
result.Field0 = colontmp_;
result.Field1 = colontmp__2;
{
int T3_;
T3_ = (int)0;
T3_ = stat(nimToCStringConv(path_p0), (&s));
if (!(T3_ == ((NI32)0))) goto LA4_;
{
NIM_BOOL T8_;
tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ colontmp__3;
NIM_BOOL colontmp__4;
T8_ = (NIM_BOOL)0;
T8_ = S_ISDIR(s.st_mode);
if (!T8_) goto LA9_;
colontmp__3 = ((tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ)3);
colontmp__4 = NIM_FALSE;
result.Field0 = colontmp__3;
result.Field1 = colontmp__4;
}
goto LA6_;
LA9_: ;
{
NIM_BOOL T12_;
tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ colontmp__5;
NIM_BOOL colontmp__6;
T12_ = (NIM_BOOL)0;
T12_ = S_ISREG(s.st_mode);
if (!!(T12_)) goto LA13_;
colontmp__5 = ((tyEnum_PathComponent__i8fM5ZocsqRz0g9ccV33pvQ)1);
colontmp__6 = NIM_TRUE;
result.Field0 = colontmp__5;
result.Field1 = colontmp__6;
}
goto LA6_;
LA13_: ;
LA6_: ;
}
LA4_: ;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nosdirExists)(NimStringV2 dir_p0) {
NIM_BOOL result;
struct stat res;
NIM_BOOL T1_;
int T2_;
nimZeroMem((void*)(&res), sizeof(struct stat));
T1_ = (NIM_BOOL)0;
T2_ = (int)0;
T2_ = stat(nimToCStringConv(dir_p0), (&res));
T1_ = (((NI32)0) <= T2_);
if (!(T1_)) goto LA3_;
T1_ = S_ISDIR(res.st_mode);
LA3_: ;
result = T1_;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, nossymlinkExists)(NimStringV2 link_p0) {
NIM_BOOL result;
struct stat res;
NIM_BOOL T1_;
int T2_;
nimZeroMem((void*)(&res), sizeof(struct stat));
T1_ = (NIM_BOOL)0;
T2_ = (int)0;
T2_ = lstat(nimToCStringConv(link_p0), (&res));
T1_ = (((NI32)0) <= T2_);
if (!(T1_)) goto LA3_;
T1_ = S_ISLNK(res.st_mode);
LA3_: ;
result = T1_;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, tryMoveFSObject__stdZprivateZoscommon_u93)(NimStringV2 source_p0, NimStringV2 dest_p1, NIM_BOOL isDir_p2) {
NIM_BOOL result;
int T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
T1_ = (int)0;
T1_ = rename(nimToCStringConv(source_p0), nimToCStringConv(dest_p1));
result = (T1_ == ((NI32)0));
{
NI32 err;
NIM_BOOL isAccessDeniedError;
if (!!(result)) goto LA4_;
err = osLastError__stdZoserrors_u122();
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
isAccessDeniedError = (err == ((NI32)18));
{
NimStringV2 colontmpD_;
tyTuple__UV3llMMYFckfui8YMBuUZA T11_;
if (!!(isAccessDeniedError)) goto LA8_;
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
T11_.Field0 = source_p0;
T11_.Field1 = dest_p1;
colontmpD_ = dollar___stdZprivateZoscommon_u100((&T11_));
if (NIM_UNLIKELY(*nimErr_)) goto LA10_;
raiseOSError__stdZoserrors_u119(err, colontmpD_);
if (NIM_UNLIKELY(*nimErr_)) goto LA10_;
{
LA10_:;
}
{
eqdestroy___system_u2597(colontmpD_);
}
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}
LA8_: ;
}
LA4_: ;
}BeforeRet_: ;
return result;
}
|