/// <summary> /// Same as <see cref="IsEqualTimestampLastAccessed"/> but does not check the param for null /// </summary> private Boolean InternalIsEqualTimestampLastAccessed( QuickIOFileInfo file ) { Contract.Requires( file != null ); int result = ( this.LastAccessTimeUtc.CompareTo( file.LastAccessTimeUtc ) ); return ( result == 0 ); // result < 0: file1 is earlier, result > 0: file1 is later. 0 = equal }
/// <summary> /// Returns the chunks of current file that are NOT identical with the other file /// </summary> /// <param name="file">File to compare</param> /// <param name="chunkSize">Chunk size (Bytes)</param> /// <returns>Returns the chunks of current file that are NOT identical with the other file</returns> public IEnumerable <QuickIOFileChunk> GetFileChunksUnequal(QuickIOFileInfo file, Int32 chunkSize = DefaultChunkSize) { var en1 = GetFileChunksEnumerator(chunkSize); var en2 = file.GetFileChunksEnumerator(chunkSize); while (en1.MoveNext( )) { var mn2 = en2.MoveNext( ); // EOF of file2? if (!mn2) { // current chunk must be unequal yield return(en1.Current); } else { // check of the chunks are unequal if (!en1.Current.ChunkEquals(en2.Current)) { // unequal yield return(en1.Current); } } } }
/// <summary> /// Returns the chunks of current file that are NOT identical with the other file /// </summary> /// <param name="file">File to compare</param> /// <param name="chunkSize">Chunk size (Bytes)</param> /// <returns>Returns the chunks of current file that are NOT identical with the other file</returns> public IEnumerable<QuickIOFileChunk> GetFileChunksUnequal( QuickIOFileInfo file, Int32 chunkSize = DefaultChunkSize ) { var en1 = GetFileChunksEnumerator( chunkSize ); var en2 = file.GetFileChunksEnumerator( chunkSize ); while ( en1.MoveNext( ) ) { var mn2 = en2.MoveNext( ); // EOF of file2? if ( !mn2 ) { // current chunk must be unequal yield return en1.Current; } else { // check of the chunks are unequal if ( !en1.Current.ChunkEquals( en2.Current ) ) { // unequal yield return en1.Current; } } } }
/// <summary> /// Checks if both file contents are equal. /// Opens both files for read and breaks on first unequal chunk. /// </summary> /// <param name="file">File to compare</param> /// <param name="chunkSize">Chunk size (Bytes)</param> /// <returns>true if contents are equal</returns> public Boolean IsEqualContents(QuickIOFileInfo file, Int32 chunkSize = DefaultChunkSize) { var en1 = GetFileChunksEnumerator(chunkSize); var en2 = file.GetFileChunksEnumerator(chunkSize); while (true) { // Go to next element var mn1 = en1.MoveNext( ); var mn2 = en2.MoveNext( ); // check if next element exists if (mn1 != mn2) { // collections count diff return(false); } // no more elements in both collections if (!mn1) { return(true); } // check chunks var chunk1 = en1.Current; var chunk2 = en2.Current; if (!chunk1.ChunkEquals(chunk2)) { return(false); } } }
/// <summary> /// Same as <see cref="IsEqualTimestampLastAccessed"/> but does not check the param for null /// </summary> private Boolean InternalIsEqualTimestampLastAccessed(QuickIOFileInfo file) { Contract.Requires(file != null); int result = (this.LastAccessTimeUtc.CompareTo(file.LastAccessTimeUtc)); return(result == 0); // result < 0: file1 is earlier, result > 0: file1 is later. 0 = equal }
/// <summary> /// Adds the specified attribute to file or directory /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attribute">Attribute to add </param> /// <returns>true if added. false if already exists in attributes</returns> public static bool AddAttribute(QuickIOFileInfo info, FileAttributes attribute) { FileAttributes updatedAttributes; bool result = QuickIOEngine.TryAddAttribute(info.FullNameUnc, attribute, out updatedAttributes); info.Attributes = updatedAttributes; return(result); }
/// <summary> /// Removes the specified attribute from file or directory /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attribute">Attribute to remove </param> /// <returns>true if removed. false if not exists in attributes</returns> public static bool RemoveAttribute(QuickIOFileInfo info, FileAttributes attribute) { Contract.Requires(info != null); FileAttributes updatedAttributes; bool result = QuickIOEngine.TryRemoveAttribute(info.FullNameUnc, attribute, out updatedAttributes); info.Attributes = updatedAttributes; return(result); }
/// <summary> /// Copies an existing file. Overwrites an existing file if <paramref name="overwrite"/> is true /// </summary> /// <param name="sourceFileName">The file to copy.</param> /// <param name="targetDirectory">Target directory</param> /// <param name="newFileName">New File name. Null or empty to use <paramref name="sourceFileName"/>' name</param> /// <param name="overwrite">true to overwrite existing files</param> /// <remarks>http://msdn.microsoft.com/en-us/library/c6cfw35a(v=vs.110).aspx</remarks> public static void CopyToDirectory( QuickIOFileInfo sourceFileName, QuickIODirectoryInfo targetDirectory, String newFileName = null, Boolean overwrite = false ) { var targetFileName = sourceFileName.Name; if ( !String.IsNullOrEmpty( newFileName ) ) { // TODO: Check for invalid chars targetFileName = newFileName; } Copy( sourceFileName.FullNameUnc, QuickIOPath.Combine( targetDirectory.FullNameUnc, targetFileName ), overwrite ); }
/// <summary> /// Returns the chunks of current file that are identical with the other file /// </summary> /// <param name="file">File to compare</param> /// <param name="chunkSize">Chunk size (Bytes)</param> /// <returns>Returns the chunks of current file that are identical with the other file</returns> public IEnumerable <QuickIOFileChunk> GetFileChunksEqual(QuickIOFileInfo file, Int32 chunkSize = DefaultChunkSize) { var en1 = GetFileChunksEnumerator(chunkSize); var en2 = file.GetFileChunksEnumerator(chunkSize); while (en1.MoveNext( ) && en2.MoveNext( )) { // check of the chunks are equal if (en1.Current.ChunkEquals(en2.Current)) { // equal yield return(en1.Current); } } }
/// <summary> /// Returns the chunks of current file that are identical with the other file /// </summary> /// <param name="file">File to compare</param> /// <param name="chunkSize">Chunk size (Bytes)</param> /// <returns>Returns the chunks of current file that are identical with the other file</returns> public IEnumerable<QuickIOFileChunk> GetFileChunksEqual( QuickIOFileInfo file, Int32 chunkSize = DefaultChunkSize ) { var en1 = GetFileChunksEnumerator( chunkSize ); var en2 = file.GetFileChunksEnumerator( chunkSize ); while ( en1.MoveNext( ) && en2.MoveNext( ) ) { // check of the chunks are equal if ( en1.Current.ChunkEquals( en2.Current ) ) { // equal yield return en1.Current; } } }
/// <summary> /// Copies an existing file. Overwrites an existing file if <paramref name="overwrite"/> is true /// </summary> /// <param name="sourceFileName">The file to copy.</param> /// <param name="targetDirectory">Target directory</param> /// <param name="newFileName">New File name. Null or empty to use <paramref name="sourceFileName"/>' name</param> /// <param name="overwrite">true to overwrite existing files</param> /// <remarks>http://msdn.microsoft.com/en-us/library/c6cfw35a(v=vs.110).aspx</remarks> /// <exception cref="FileSystemIsBusyException">Filesystem is busy</exception> public static void CopyToDirectory( QuickIOFileInfo sourceFileName, QuickIODirectoryInfo targetDirectory, String newFileName = null, Boolean overwrite = false ) { Contract.Requires( sourceFileName != null ); Contract.Requires( targetDirectory != null ); if( sourceFileName == null ) { throw new ArgumentNullException( nameof( sourceFileName ) ); } if( targetDirectory == null ) { throw new ArgumentNullException( nameof( targetDirectory ) ); } CopyToDirectory( sourceFileName.FullNameUnc, targetDirectory.FullNameUnc, newFileName, overwrite ); }
/// <summary> /// Copies an existing file. Overwrites an existing file if <paramref name="overwrite"/> is true /// </summary> /// <param name="sourceFileName">The file to copy.</param> /// <param name="targetDirectory">Target directory</param> /// <param name="newFileName">New File name. Null or empty to use <paramref name="sourceFileName"/>' name</param> /// <param name="overwrite">true to overwrite existing files</param> /// <remarks>http://msdn.microsoft.com/en-us/library/c6cfw35a(v=vs.110).aspx</remarks> /// <exception cref="FileSystemIsBusyException">Filesystem is busy</exception> public static void CopyToDirectory(QuickIOFileInfo sourceFileName, QuickIODirectoryInfo targetDirectory, String newFileName = null, Boolean overwrite = false) { Contract.Requires(sourceFileName != null); Contract.Requires(targetDirectory != null); if (sourceFileName == null) { throw new ArgumentNullException(nameof(sourceFileName)); } if (targetDirectory == null) { throw new ArgumentNullException(nameof(targetDirectory)); } CopyToDirectory(sourceFileName.FullNameUnc, targetDirectory.FullNameUnc, newFileName, overwrite); }
/// <summary> /// Checks all timestamps. /// </summary> /// <param name="file">File to compare with</param> /// <returns>If collection is empty, all timestamps are equal. Otherwise unequal timestamp is returned.</returns> public IEnumerable<QuickIOFileCompareCriteria> CompareTimestamps( QuickIOFileInfo file ) { Invariant.NotNull( file ); if ( InternalIsEqualTimestampCreated( file ) ) { yield return QuickIOFileCompareCriteria.TimestampCreated; } if ( InternalIsEqualTimestampLastAccessed( file ) ) { yield return QuickIOFileCompareCriteria.TimestampLastAccessed; } if ( InternalIsEqualTimestampsLastWritten( file ) ) { yield return QuickIOFileCompareCriteria.TimestampLastWritten; } }
/// <summary> /// Checks all timestamps. /// </summary> /// <param name="file">File to compare with</param> /// <returns>If collection is empty, all timestamps are equal. Otherwise unequal timestamp is returned.</returns> public IEnumerable<QuickIOFileCompareCriteria> CompareTimestamps( QuickIOFileInfo file ) { Contract.Requires( file != null ); if ( InternalIsEqualTimestampCreated( file ) ) { yield return QuickIOFileCompareCriteria.TimestampCreated; } if ( InternalIsEqualTimestampLastAccessed( file ) ) { yield return QuickIOFileCompareCriteria.TimestampLastAccessed; } if ( InternalIsEqualTimestampsLastWritten( file ) ) { yield return QuickIOFileCompareCriteria.TimestampLastWritten; } }
/// <summary> /// Checks all timestamps. /// </summary> /// <param name="file">File to compare with</param> /// <returns>If collection is empty, all timestamps are equal. Otherwise unequal timestamp is returned.</returns> public IEnumerable <QuickIOFileCompareCriteria> CompareTimestamps(QuickIOFileInfo file) { Contract.Requires(file != null); if (InternalIsEqualTimestampCreated(file)) { yield return(QuickIOFileCompareCriteria.TimestampCreated); } if (InternalIsEqualTimestampLastAccessed(file)) { yield return(QuickIOFileCompareCriteria.TimestampLastAccessed); } if (InternalIsEqualTimestampsLastWritten(file)) { yield return(QuickIOFileCompareCriteria.TimestampLastWritten); } }
/// <summary> /// Checks byte length (NOT CONTENTS!) /// </summary> /// <param name="file">File to compare with</param> /// <returns>Returns true if both <see cref="QuickIOFileInfo.Bytes"/> properties are equal</returns> public Boolean IsEqualByteLength( QuickIOFileInfo file ) { Contract.Requires( file != null ); return ( this.Bytes == file.Bytes ); }
/// <summary> /// Returns the time of the file or directory was last written (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure. (UTC)</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetimeutc(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetLastWriteTimeUtc( QuickIOFileInfo info ) { return info.FindData.GetLastWriteTimeUtc( ); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static FileAttributes GetAttributes(QuickIOFileInfo info) { Contract.Requires(info != null); return(GetAttributes(info.PathInfo)); }
/// <summary> /// Adds the specified attribute to file or directory /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attribute">Attribute to add </param> /// <returns>true if added. false if already exists in attributes</returns> public static bool AddAttribute(QuickIOFileInfo info, FileAttributes attribute) { Contract.Requires(info != null); return(AddAttribute(info.PathInfo, attribute)); }
/// <summary> /// Defines the time at which the file or directory was last written (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setlastwritetimeutc(v=vs.110).aspx</remarks> public static void SetLastWriteTimeUtc(QuickIOFileInfo info, DateTime lastWriteTimeUtc) { QuickIOEngine.SetLastWriteTimeUtc(info.FullNameUnc, lastWriteTimeUtc); }
/// <summary> /// Returns the creation time of the file or directory /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure.</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getcreationtime(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetCreationTime(QuickIOFileInfo info) { return(GetCreationTimeUtc(info.PathInfo).ToLocalTime( )); }
/// <summary> /// Defines the time at which the file or directory was created /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTime">The time that is to be used</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.110).aspx</remarks> public static void SetCreationTime(QuickIOFileInfo info, DateTime creationTime) { QuickIOEngine.SetCreationTimeUtc(info.FullNameUnc, creationTime.ToUniversalTime( )); }
/// <summary> /// Checks byte length (NOT CONTENTS!) /// </summary> /// <param name="file">File to compare with</param> /// <returns>Returns true if both <see cref="QuickIOFileInfo.Bytes"/> properties are equal</returns> public Boolean IsEqualByteLength( QuickIOFileInfo file ) { Invariant.NotNull( file ); return ( this.Bytes == file.Bytes ); }
/// <summary> /// Returns the root information /// </summary> /// <param name="info">A file or directory. </param> /// <returns>A QuickIOPathInfo that represents the root or null if <paramref name="info"/> is root.</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.directory.getdirectoryroot(v=vs.110).aspx</remarks> public static Task<QuickIOPathInfo> GetDirectoryRootAsync( QuickIOFileInfo info ) { return NETCompatibility.AsyncExtensions.GetAsyncResult( ( ) => QuickIOFile.GetDirectoryRoot( info ) ); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attributes">New attributes to set.</param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static FileAttributes SetAttributes( QuickIOFileInfo info, FileAttributes attributes ) { return SetAttributes( info.PathInfo, attributes ); }
/// <summary> /// Removes the specified attribute from file or directory /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attribute">Attribute to remove </param> /// <returns>true if removed. false if not exists in attributes</returns> public static bool RemoveAttribute( QuickIOFileInfo info, FileAttributes attribute ) { return RemoveAttribute( info.PathInfo, attribute ); }
/// <summary> /// Sets the time the file was created. /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTime">The time that is to be used</param> /// <param name="lastAccessTime">The time that is to be used</param> /// <param name="lastWriteTime">The time that is to be used</param> public static void SetAllFileTimes(QuickIOFileInfo info, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime) { SetAllFileTimesUtc(info, creationTime.ToUniversalTime( ), lastAccessTime.ToUniversalTime( ), lastWriteTime.ToUniversalTime( )); }
/// <summary> /// Sets the dates and times of given directory or file. /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTimeUtc">The time that is to be used (UTC)</param> /// <param name="lastAccessTimeUtc">The time that is to be used (UTC)</param> /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param> public static void SetAllFileTimesUtc(QuickIOFileInfo info, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc) { InternalQuickIO.SetAllFileTimes(info.PathInfo, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc); }
/// <summary> /// Checks if both file contents are equal. /// Opens both files for read and breaks on first unequal chunk. /// </summary> /// <param name="file">File to compare</param> /// <param name="chunkSize">Chunk size (Bytes)</param> /// <returns>true if contents are equal</returns> public Boolean IsEqualContents( QuickIOFileInfo file, Int32 chunkSize = DefaultChunkSize ) { var en1 = GetFileChunksEnumerator( chunkSize ); var en2 = file.GetFileChunksEnumerator( chunkSize ); while ( true ) { // Go to next element var mn1 = en1.MoveNext( ); var mn2 = en2.MoveNext( ); // check if next element exists if ( mn1 != mn2 ) { // collections count diff return false; } // no more elements in both collections if ( !mn1 ) { return true; } // check chunks var chunk1 = en1.Current; var chunk2 = en2.Current; if ( !chunk1.ChunkEquals( chunk2 ) ) { return false; } } }
/// <summary> /// Defines the time at which the file or directory was created (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTimeUtc">The time that is to be used (UTC)</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setcreationtimeutc(v=vs.110).aspx</remarks> public static void SetCreationTimeUtc(QuickIOFileInfo info, DateTime creationTimeUtc) { InternalQuickIO.SetCreationTimeUtc(info.PathInfo, creationTimeUtc); }
/// <summary> /// Sets the dates and times of given directory or file. /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTimeUtc">The time that is to be used (UTC)</param> /// <param name="lastAccessTimeUtc">The time that is to be used (UTC)</param> /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param> public static void SetAllFileTimesUtc(QuickIOFileInfo info, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc) { QuickIOEngine.SetAllFileTimes(info.FullNameUnc, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc); }
/// <summary> /// Checks whether the specified file exists. /// </summary> /// <param name="fileInfo">The the file to check.</param> /// <returns><b>true</b> if the caller has the required permissions and path contains the name of an existing file; otherwise, <b>false</b></returns> /// <remarks>The original Exists method returns also false on null! http://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx</remarks> /// <exception cref="UnmatchedFileSystemEntryTypeException">Searched for file but found folder.</exception> /// <exception cref="InvalidPathException">Path is invalid.</exception> public static bool Exists( QuickIOFileInfo fileInfo ) { Contract.Requires( fileInfo != null ); return Exists( fileInfo.FullNameUnc ); }
/// <summary> /// Defines the time at which the file or directory was created (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTimeUtc">The time that is to be used (UTC)</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setcreationtimeutc(v=vs.110).aspx</remarks> public static void SetCreationTimeUtc(QuickIOFileInfo info, DateTime creationTimeUtc) { QuickIOEngine.SetCreationTimeUtc(info.FullNameUnc, creationTimeUtc); }
/// <summary> /// Returns the creation time of the file or directory /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure.</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getcreationtime(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetCreationTime( QuickIOFileInfo info ) { return GetCreationTimeUtc( info.PathInfo ).ToLocalTime( ); }
/// <summary> /// Defines the time at which the file or directory was last written /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="lastWriteTime">The time that is to be used</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setlastwritetime(v=vs.110).aspx</remarks> public static void SetLastWriteTime(QuickIOFileInfo info, DateTime lastWriteTime) { QuickIOEngine.SetLastWriteTimeUtc(info.FullNameUnc, lastWriteTime.ToUniversalTime( )); }
/// <summary> /// Returns the creation time of the file or directory (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure. (UTC)</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getcreationtimeutc(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetCreationTimeUtc( QuickIOFileInfo info ) { return info.FindData.GetCreationTimeUtc( ); }
/// <summary> /// Returns the creation time of the file or directory (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure. (UTC)</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getcreationtimeutc(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetCreationTimeUtc(QuickIOFileInfo info) { return(info.FindData.GetCreationTimeUtc( )); }
/// <summary> /// Sets the dates and times of given directory or file. /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTimeUtc">The time that is to be used (UTC)</param> /// <param name="lastAccessTimeUtc">The time that is to be used (UTC)</param> /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param> public static void SetAllFileTimesUtc( QuickIOFileInfo info, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc ) { InternalQuickIO.SetAllFileTimes( info.PathInfo, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc ); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attributes">New attributes to set.</param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static void SetAttributes(QuickIOFileInfo info, FileAttributes attributes) { Contract.Requires(info != null); SetAttributes(info.PathInfo, attributes); }
/// <summary> /// Defines the time at which the file or directory was created (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTimeUtc">The time that is to be used (UTC)</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setcreationtimeutc(v=vs.110).aspx</remarks> public static void SetCreationTimeUtc( QuickIOFileInfo info, DateTime creationTimeUtc ) { InternalQuickIO.SetCreationTimeUtc( info.PathInfo, creationTimeUtc ); }
/// <summary> /// Returns the time of last access of the file or directory /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure.</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getlastaccesstime(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetLastAccessTime( QuickIOFileInfo info ) { return GetLastAccessTimeUtc( info.PathInfo ).ToLocalTime( ); }
/// <summary> /// Defines the time at which the file or directory was last written /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="lastWriteTime">The time that is to be used</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setlastwritetime(v=vs.110).aspx</remarks> public static void SetLastWriteTime(QuickIOFileInfo info, DateTime lastWriteTime) { SetLastWriteTimeUtc(info, lastWriteTime.ToUniversalTime( )); }
/// <summary> /// Sets the time the file was created. /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTime">The time that is to be used</param> /// <param name="lastAccessTime">The time that is to be used</param> /// <param name="lastWriteTime">The time that is to be used</param> public static void SetAllFileTimes( QuickIOFileInfo info, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime ) { SetAllFileTimesUtc( info, creationTime.ToUniversalTime( ), lastAccessTime.ToUniversalTime( ), lastWriteTime.ToUniversalTime( ) ); }
/// <summary> /// Defines the time at which the file or directory was created /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTime">The time that is to be used</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.110).aspx</remarks> public static void SetCreationTime(QuickIOFileInfo info, DateTime creationTime) { SetCreationTimeUtc(info, creationTime.ToUniversalTime( )); }
/// <summary> /// Defines the time at which the file or directory was created /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTime">The time that is to be used</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setcreationtime(v=vs.110).aspx</remarks> public static void SetCreationTime( QuickIOFileInfo info, DateTime creationTime ) { SetCreationTimeUtc( info, creationTime.ToUniversalTime( ) ); }
/// <summary> /// Adds the specified attribute to file or directory /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attribute">Attribute to add </param> /// <returns>true if added. false if already exists in attributes</returns> public static Task<bool> AddAttributeAsync( QuickIOFileInfo info, FileAttributes attribute ) { return NETCompatibility.AsyncExtensions.GetAsyncResult( ( ) => QuickIOFile.AddAttribute( info, attribute ) ); }
/// <summary> /// Defines the time at which the file or directory was last written /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="lastWriteTime">The time that is to be used</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setlastwritetime(v=vs.110).aspx</remarks> public static void SetLastWriteTime( QuickIOFileInfo info, DateTime lastWriteTime ) { SetLastWriteTimeUtc( info, lastWriteTime.ToUniversalTime( ) ); }
/// <summary> /// Defines the time at which the file or directory was last written (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setlastwritetimeutc(v=vs.110).aspx</remarks> public static void SetLastWriteTimeUtc(QuickIOFileInfo info, DateTime lastWriteTimeUtc) { InternalQuickIO.SetLastWriteTimeUtc(info.PathInfo, lastWriteTimeUtc); }
/// <summary> /// Defines the time at which the file or directory was last written (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="lastWriteTimeUtc">The time that is to be used (UTC)</param> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.setlastwritetimeutc(v=vs.110).aspx</remarks> public static void SetLastWriteTimeUtc( QuickIOFileInfo info, DateTime lastWriteTimeUtc ) { InternalQuickIO.SetLastWriteTimeUtc( info.PathInfo, lastWriteTimeUtc ); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attributes">New attributes to set.</param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static void SetAttributes( QuickIOFileInfo info, FileAttributes attributes ) { InternalQuickIO.SetAttributes( info.PathInfo, attributes); }
/// <summary> /// Returns the if timestamp 'last written to' is equal /// </summary> /// <param name="file">File to compare with</param> /// <returns>Returns the if timestamp 'last written to' is equal</returns> public Boolean IsEqualTimestampsLastWritten(QuickIOFileInfo file) { Contract.Requires(file != null); return(InternalIsEqualTimestampsLastWritten(file)); }
/// <summary> /// Adds the specified attribute to file or directory /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attribute">Attribute to add </param> /// <returns>true if added. false if already exists in attributes</returns> public static bool AddAttribute( QuickIOFileInfo info, FileAttributes attribute ) { return InternalQuickIO.AddAttribute( info.PathInfo, attribute ); }
/// <summary> /// Returns the if timestamp 'last accessed' is equal /// </summary> /// <param name="file">File to compare with</param> /// <returns>Returns the if timestamp 'last accessed' is equal</returns> public Boolean IsEqualTimestampLastAccessed(QuickIOFileInfo file) { Contract.Requires(file != null); return(InternalIsEqualTimestampLastAccessed(file)); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static FileAttributes GetAttributes( QuickIOFileInfo info ) { return InternalQuickIO.GetAttributes( info.PathInfo ); }
/// <summary> /// Checks whether the specified file exists. /// </summary> /// <param name="fileInfo">The the file to check.</param> /// <returns><b>true</b> if the caller has the required permissions and path contains the name of an existing file; otherwise, <b>false</b></returns> /// <remarks>The original Exists method returns also false on null! http://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx</remarks> /// <exception cref="UnmatchedFileSystemEntryTypeException">Searched for file but found folder.</exception> /// <exception cref="InvalidPathException">Path is invalid.</exception> public static bool Exists(QuickIOFileInfo fileInfo) { Contract.Requires(fileInfo != null); return(Exists(fileInfo.FullNameUnc)); }
/// <summary> /// Returns the time of last access of the file or directory /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure.</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getlastaccesstime(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetLastAccessTime(QuickIOFileInfo info) { return(GetLastAccessTimeUtc(info.PathInfo).ToLocalTime( )); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <param name="attributes">New attributes to set.</param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static Task SetAttributesAsync( QuickIOFileInfo info, FileAttributes attributes ) { return NETCompatibility.AsyncExtensions.ExecuteAsync( ( ) => QuickIOFile.SetAttributes( info.PathInfo, attributes) ); }
/// <summary> /// Returns the time of the file or directory was last written (UTC) /// </summary> /// <param name="info">Affected file or directory</param> /// <returns>A <see cref="DateTime"/> structure. (UTC)</returns> /// <remarks>http://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetimeutc(v=vs.110).aspx</remarks> /// <exception cref="PathNotFoundException">No entry found for passed path</exception> public static DateTime GetLastWriteTimeUtc(QuickIOFileInfo info) { return(info.FindData.GetLastWriteTimeUtc( )); }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the directory or file. /// </summary> /// <param name="info">A directory or file. </param> /// <returns>The <see cref="FileAttributes"/> of the directory or file.</returns> public static Task<FileAttributes> GetAttributesAsync( QuickIOFileInfo info ) { return NETCompatibility.AsyncExtensions.GetAsyncResult( ( ) => QuickIOFile.GetAttributes( info ) ); }
/// <summary> /// Sets the time the file was created. /// </summary> /// <param name="info">Affected file or directory</param> /// <param name="creationTime">The time that is to be used</param> /// <param name="lastAccessTime">The time that is to be used</param> /// <param name="lastWriteTime">The time that is to be used</param> public static void SetAllFileTimes(QuickIOFileInfo info, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime) { QuickIOEngine.SetAllFileTimes(info.FullNameUnc, creationTime.ToUniversalTime( ), lastAccessTime.ToUniversalTime( ), lastWriteTime.ToUniversalTime( )); }