Exemple #1
0
        public long GetFileSize(SafeFileHandle handle)
        {
            if (!WinNative.GetFileSizeEx(handle, out var size))
            {
                throw new Win32Exception();
            }

            return(size);
        }
Exemple #2
0
        public static long GetFileSize(SafeFileHandle handle)
        {
#if !__MonoCS__ && !USE_UNIX_IO
            long size = 0;
            if (!WinNative.GetFileSizeEx(handle, out size))
            {
                throw new Win32Exception();
            }
            return(size);
#else
            Stat s;
            int  r;
            do
            {
                r = (int)Syscall.fstat(handle.DangerousGetHandle().ToInt32(), out s);
            } while (UnixMarshal.ShouldRetrySyscall(r));
            UnixMarshal.ThrowExceptionForLastErrorIf(r);
            return(s.st_size);
#endif
        }