Пример #1
0
        private static unsafe Interop.Error SetCreationTimeCore(string path, long seconds, long nanoseconds)
        {
            Interop.Sys.TimeSpec timeSpec = default;

            timeSpec.TvSec  = seconds;
            timeSpec.TvNsec = nanoseconds;

            Interop.libc.AttrList attrList = default;
            attrList.bitmapCount = Interop.libc.AttrList.ATTR_BIT_MAP_COUNT;
            attrList.commonAttr  = Interop.libc.AttrList.ATTR_CMN_CRTIME;

            Interop.Error error =
                Interop.libc.setattrlist(path, &attrList, &timeSpec, sizeof(Interop.Sys.TimeSpec), new CULong(Interop.libc.FSOPT_NOFOLLOW)) == 0 ?
                Interop.Error.SUCCESS :
                Interop.Sys.GetLastErrorInfo().Error;

            return(error);
        }
Пример #2
0
        private static unsafe Interop.Error SetCreationTimeCore(SafeFileHandle?handle, string?path, long seconds, long nanoseconds)
        {
            Debug.Assert(handle is not null || path is not null);
            Interop.Sys.TimeSpec timeSpec = default;

            timeSpec.TvSec  = seconds;
            timeSpec.TvNsec = nanoseconds;

            Interop.libc.AttrList attrList = default;
            attrList.bitmapCount = Interop.libc.AttrList.ATTR_BIT_MAP_COUNT;
            attrList.commonAttr  = Interop.libc.AttrList.ATTR_CMN_CRTIME;

            int result = handle is not null
                ? Interop.libc.fsetattrlist(handle, &attrList, &timeSpec, sizeof(Interop.Sys.TimeSpec), new CULong(Interop.libc.FSOPT_NOFOLLOW))
                : Interop.libc.setattrlist(path !, &attrList, &timeSpec, sizeof(Interop.Sys.TimeSpec), new CULong(Interop.libc.FSOPT_NOFOLLOW));

            return(result == 0 ?
                   Interop.Error.SUCCESS :
                   Interop.Sys.GetLastErrorInfo().Error);
        }