Files
duplicati/Duplicati/Library/Common/IO/ISystemIO.cs
T

88 lines
4.2 KiB
C#
Raw Normal View History

2024-02-28 15:45:30 +01:00
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
2014-03-18 10:59:06 +01:00
using System;
using System.IO;
using System.Collections.Generic;
using Duplicati.Library.Interface;
2018-11-02 21:34:07 +01:00
namespace Duplicati.Library.Common.IO
2014-03-18 10:59:06 +01:00
{
/// <summary>
/// Interface for wrapping System.IO operations.
/// </summary>
public interface ISystemIO
{
2018-11-01 17:56:48 +01:00
IFileEntry DirectoryEntry(string path);
2023-11-19 20:04:37 +01:00
IFileEntry DirectoryEntry(DirectoryInfo dirInfo);
2014-03-18 10:59:06 +01:00
void DirectoryCreate(string path);
void DirectoryDelete(string path, bool recursive);
2014-03-18 10:59:06 +01:00
bool DirectoryExists(string path);
void DirectoryMove(string sourceDirName, string destDirName);
2014-03-18 10:59:06 +01:00
void DirectorySetLastWriteTimeUtc(string path, DateTime time);
void DirectorySetCreationTimeUtc(string path, DateTime time);
2018-11-01 17:56:48 +01:00
IFileEntry FileEntry(string path);
2023-11-19 20:04:37 +01:00
IFileEntry FileEntry(FileInfo fileInfo);
2014-03-18 10:59:06 +01:00
void FileMove(string source, string target);
void FileDelete(string path);
2018-11-01 17:56:48 +01:00
void FileCopy(string source, string target, bool overwrite);
2014-03-18 10:59:06 +01:00
void FileSetLastWriteTimeUtc(string path, DateTime time);
void FileSetCreationTimeUtc(string path, DateTime time);
DateTime FileGetLastWriteTimeUtc(string path);
DateTime FileGetCreationTimeUtc(string path);
2014-03-18 10:59:06 +01:00
bool FileExists(string path);
long FileLength(string path);
2018-11-01 17:56:48 +01:00
FileStream FileOpenRead(string path);
FileStream FileOpenWrite(string path);
FileStream FileCreate(string path);
2014-03-18 10:59:06 +01:00
FileAttributes GetFileAttributes(string path);
void SetFileAttributes(string path, FileAttributes attributes);
2014-03-18 10:59:06 +01:00
void CreateSymlink(string symlinkfile, string target, bool asDir);
string GetSymlinkTarget(string path);
2014-03-18 10:59:06 +01:00
string PathGetDirectoryName(string path);
string PathGetFileName(string path);
2014-03-18 10:59:06 +01:00
string PathGetExtension(string path);
string PathChangeExtension(string path, string extension);
string PathCombine(params string[] paths);
2018-11-01 17:56:48 +01:00
string PathGetFullPath(string path);
string GetPathRoot(string path);
string[] GetDirectories(string path);
string[] GetFiles(string path);
string[] GetFiles(string path, string searchPattern);
DateTime GetCreationTimeUtc(string path);
DateTime GetLastWriteTimeUtc(string path);
IEnumerable<string> EnumerateFileSystemEntries(string path);
IEnumerable<string> EnumerateFiles(string path);
IEnumerable<string> EnumerateFiles(string path, string searchPattern, SearchOption searchOption);
2018-11-01 17:56:48 +01:00
IEnumerable<string> EnumerateDirectories(string path);
2023-11-19 20:04:37 +01:00
// Enumerate FileEntries of files and directories
// This is more efficient than enumerating file names when metadata is needed
IEnumerable<IFileEntry> EnumerateFileEntries(string path);
2014-11-30 21:32:31 +01:00
void SetMetadata(string path, Dictionary<string, string> metdata, bool restorePermissions);
Dictionary<string, string> GetMetadata(string path, bool isSymlink, bool followSymlink);
2014-03-18 10:59:06 +01:00
}
2018-11-01 17:56:48 +01:00
2014-03-18 10:59:06 +01:00
}