Beispiel #1
0
        protected override Result GetFileTimeStampRawImpl(out FileTimeStampRaw timeStamp, string path)
        {
            return(BaseFs.GetFileTimeStampRaw(out timeStamp, path));

            // FS does:
            // return ResultFs.NotImplemented.Log();
        }
Beispiel #2
0
        // GetFileTimeStampRaw(buffer<bytes<0x301>, 0x19, 0x301> path) -> bytes<0x20> timestamp
        public long GetFileTimeStampRaw(ServiceCtx context)
        {
            string name = ReadUtf8String(context);

            try
            {
                FileTimeStampRaw timestamp = _fileSystem.GetFileTimeStampRaw(name);

                context.ResponseData.Write(timestamp.Created);
                context.ResponseData.Write(timestamp.Modified);
                context.ResponseData.Write(timestamp.Accessed);

                byte[] data = new byte[8];

                // is valid?
                data[0] = 1;

                context.ResponseData.Write(data);
            }
            catch (HorizonResultException ex)
            {
                return(ex.ResultValue.Value);
            }

            return(0);
        }
Beispiel #3
0
        protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            timeStamp = default;

            Result rc = ResolveFullPath(out string fullPath, path);

            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = GetFileInfo(out FileInfo file, fullPath);
            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!file.Exists)
            {
                return(ResultFs.PathNotFound.Log());
            }

            timeStamp.Created  = new DateTimeOffset(file.CreationTimeUtc).ToUnixTimeSeconds();
            timeStamp.Accessed = new DateTimeOffset(file.LastAccessTimeUtc).ToUnixTimeSeconds();
            timeStamp.Modified = new DateTimeOffset(file.LastWriteTime).ToUnixTimeSeconds();

            return(Result.Success);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the creation, last accessed, and last modified timestamps of a file or directory.
        /// </summary>
        /// <param name="timeStamp">If the operation returns successfully, the timestamps for the specified file or directory.
        /// These value are expressed as Unix timestamps.</param>
        /// <param name="path">The path of the file or directory.</param>
        /// <returns>The <see cref="Result"/> of the requested operation.</returns>
        /// <remarks>
        /// The following <see cref="Result"/> codes may be returned under certain conditions:
        ///
        /// The specified path does not exist: <see cref="ResultFs.PathNotFound"/>
        /// </remarks>
        public Result GetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            if (path.IsNull())
            {
                UnsafeHelpers.SkipParamInit(out timeStamp);
                return(ResultFs.NullptrArgument.Log());
            }

            return(DoGetFileTimeStampRaw(out timeStamp, path));
        }
Beispiel #5
0
        /// <summary>
        /// Gets the creation, last accessed, and last modified timestamps of a file or directory.
        /// </summary>
        /// <param name="timeStamp">If the operation returns successfully, the timestamps for the specified file or directory.
        /// These value are expressed as Unix timestamps.</param>
        /// <param name="path">The path of the file or directory.</param>
        /// <returns>The <see cref="Result"/> of the requested operation.</returns>
        /// <remarks>
        /// The following <see cref="Result"/> codes may be returned under certain conditions:
        ///
        /// The specified path does not exist: <see cref="ResultFs.PathNotFound"/>
        /// </remarks>
        public Result GetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            if (path.IsNull())
            {
                timeStamp = default;
                return(ResultFs.NullptrArgument.Log());
            }

            return(DoGetFileTimeStampRaw(out timeStamp, path));
        }
Beispiel #6
0
        public FileTimeStampRaw GetFileTimeStampRaw(string path)
        {
            path = PathTools.Normalize(path);
            string localPath = ToDiscUtilsPath(path);

            FileTimeStampRaw timeStamp = default;

            timeStamp.Created  = new DateTimeOffset(Fs.GetCreationTime(localPath)).ToUnixTimeSeconds();
            timeStamp.Accessed = new DateTimeOffset(Fs.GetLastAccessTime(localPath)).ToUnixTimeSeconds();
            timeStamp.Modified = new DateTimeOffset(Fs.GetLastWriteTime(localPath)).ToUnixTimeSeconds();

            return(timeStamp);
        }
        protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            timeStamp = default;

            Span <byte> fullPath = stackalloc byte[PathTools.MaxPathLength + 1];
            Result      rc       = ResolveFullPath(fullPath, path);

            if (rc.IsFailure())
            {
                return(rc);
            }

            return(BaseFileSystem.GetFileTimeStampRaw(out timeStamp, new U8Span(fullPath)));
        }
Beispiel #8
0
        protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            foreach (IFileSystem fs in Sources)
            {
                Result getEntryResult = fs.GetEntryType(out _, path);

                if (getEntryResult.IsSuccess())
                {
                    return(fs.GetFileTimeStampRaw(out timeStamp, path));
                }
            }

            timeStamp = default;
            return(ResultFs.PathNotFound.Log());
        }
Beispiel #9
0
        protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            UnsafeHelpers.SkipParamInit(out timeStamp);

            foreach (IFileSystem fs in Sources)
            {
                Result getEntryResult = fs.GetEntryType(out _, path);

                if (getEntryResult.IsSuccess())
                {
                    return(fs.GetFileTimeStampRaw(out timeStamp, path));
                }
            }

            return(ResultFs.PathNotFound.Log());
        }
Beispiel #10
0
        protected override Result GetFileTimeStampRawImpl(out FileTimeStampRaw timeStamp, string path)
        {
            path = PathTools.Normalize(path);

            foreach (IFileSystem fs in Sources)
            {
                Result getEntryResult = fs.GetEntryType(out DirectoryEntryType type, path);

                if (getEntryResult.IsSuccess() && type != DirectoryEntryType.NotFound)
                {
                    return(fs.GetFileTimeStampRaw(out timeStamp, path));
                }
            }

            timeStamp = default;
            return(ResultFs.PathNotFound.Log());
        }
Beispiel #11
0
        protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
        {
            UnsafeHelpers.SkipParamInit(out timeStamp);

            Result rc = ResolveFullPath(out string fullPath, path, true);

            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = GetFileInfo(out FileInfo file, fullPath);
            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!file.Exists)
            {
                return(ResultFs.PathNotFound.Log());
            }

            if (_useUnixTime)
            {
                timeStamp.Created  = new DateTimeOffset(file.CreationTimeUtc).ToUnixTimeSeconds();
                timeStamp.Accessed = new DateTimeOffset(file.LastAccessTimeUtc).ToUnixTimeSeconds();
                timeStamp.Modified = new DateTimeOffset(file.LastWriteTimeUtc).ToUnixTimeSeconds();
            }
            else
            {
                timeStamp.Created  = new DateTimeOffset(file.CreationTimeUtc).ToFileTime();
                timeStamp.Accessed = new DateTimeOffset(file.LastAccessTimeUtc).ToFileTime();
                timeStamp.Modified = new DateTimeOffset(file.LastWriteTimeUtc).ToFileTime();
            }

            timeStamp.IsLocalTime = false;

            return(Result.Success);
        }
Beispiel #12
0
        protected override Result GetFileTimeStampRawImpl(out FileTimeStampRaw timeStamp, string path)
        {
            timeStamp = default;
            string localPath = ResolveLocalPath(PathTools.Normalize(path));

            Result rc = GetFileInfo(out FileInfo file, localPath);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!file.Exists)
            {
                return(ResultFs.PathNotFound.Log());
            }

            timeStamp.Created  = new DateTimeOffset(File.GetCreationTime(localPath)).ToUnixTimeSeconds();
            timeStamp.Accessed = new DateTimeOffset(File.GetLastAccessTime(localPath)).ToUnixTimeSeconds();
            timeStamp.Modified = new DateTimeOffset(File.GetLastWriteTime(localPath)).ToUnixTimeSeconds();

            return(Result.Success);
        }
Beispiel #13
0
        // GetFileTimeStampRaw(buffer<bytes<0x301>, 0x19, 0x301> path) -> bytes<0x20> timestamp
        public long GetFileTimeStampRaw(ServiceCtx context)
        {
            string name = ReadUtf8String(context);

            if (_provider.FileExists(name) || _provider.DirectoryExists(name))
            {
                FileTimeStampRaw timestamp = _provider.GetFileTimeStampRaw(name);

                context.ResponseData.Write(timestamp.Created);
                context.ResponseData.Write(timestamp.Modified);
                context.ResponseData.Write(timestamp.Accessed);

                byte[] data = new byte[8];

                // is valid?
                data[0] = 1;

                context.ResponseData.Write(data);

                return(0);
            }

            return(MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist));
        }
Beispiel #14
0
        protected override Result GetFileTimeStampRawImpl(out FileTimeStampRaw timeStamp, string path)
        {
            string fullPath = ResolveFullPath(PathTools.Normalize(path));

            return(ParentFileSystem.GetFileTimeStampRaw(out timeStamp, fullPath));
        }
Beispiel #15
0
 protected override Result GetFileTimeStampRawImpl(out FileTimeStampRaw timestamp, U8Span path)
 {
     throw new NotImplementedException();
 }
 protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
 {
     return(BaseFileSystem.GetFileTimeStampRaw(out timeStamp, path));
 }
Beispiel #17
0
 protected virtual Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
 {
     timeStamp = default;
     return(ResultFs.NotImplemented.Log());
 }
Beispiel #18
0
 protected virtual Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
 {
     UnsafeHelpers.SkipParamInit(out timeStamp);
     return(ResultFs.NotImplemented.Log());
 }
Beispiel #19
0
 protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path) =>
 BaseFileSystem.Target.GetFileTimeStampRaw(out timeStamp, path);
Beispiel #20
0
 public Result GetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
 {
     return(FileSystem.GetFileTimeStampRaw(out timeStamp, path));
 }
Beispiel #21
0
 protected override Result GetFileTimeStampRawImpl(out FileTimeStampRaw timeStamp, string path)
 {
     return(BaseFileSystem.GetFileTimeStampRaw(out timeStamp, path));
 }
Beispiel #22
0
 protected override Result DoGetFileTimeStampRaw(out FileTimeStampRaw timeStamp, U8Span path)
 {
     using var scopedLayoutType = new ScopedStorageLayoutTypeSetter(StorageFlag);
     return(BaseFileSystem.Target.GetFileTimeStampRaw(out timeStamp, path));
 }