// SmbFileExtensions.cs implementation by J. Arturo // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Threading.Tasks; using SharpCifs.Util.Sharpen; namespace SharpCifs.Smb { public static class SmbFileExtensions { /// /// Get file's creation date converted to local timezone /// /// /// public static DateTime GetLocalCreateTime(this SmbFile smbFile) { return TimeZoneInfo.ConvertTime(Extensions.CreateDateFromUTC(smbFile.CreateTime()), TimeZoneInfo.Local); } /// /// Get file's last modified date converted to local timezone /// /// /// public static DateTime GetLocalLastModified(this SmbFile smbFile) { return TimeZoneInfo.ConvertTime(Extensions.CreateDateFromUTC(smbFile.LastModified()), TimeZoneInfo.Local); } /// /// List files async /// /// /// public static Task ListFilesAsync(this SmbFile smbFile) { return Task.Run(() => smbFile.ListFiles()); } /// /// List files async /// /// /// /// public static Task ListFilesAsync(this SmbFile smbFile, string wildcard) { return Task.Run(() => smbFile.ListFiles(wildcard)); } /// /// List files async /// /// /// public static Task ListAsync(this SmbFile smbFile) { return Task.Run(() => smbFile.List()); } /// /// MkDir async method /// /// /// public static Task MkDirAsync(this SmbFile smbFile) { return Task.Run(() => smbFile.Mkdir()); } /// /// Delete file async /// /// /// public static Task DeleteAsync(this SmbFile smbFile) { return Task.Run(() => smbFile.Delete()); } /// /// Rename file async /// /// /// /// public static Task RenameToAsync(this SmbFile smbFile, SmbFile destination) { return Task.Run(() => smbFile.RenameTo(destination)); } /// /// Get input stream async /// /// /// public static Task GetInputStreamAsync(this SmbFile smbFile) { return Task.Run(() => smbFile.GetInputStream()); } /// /// Get output stream async /// /// /// /// public static Task GetOutputStreamAsync(this SmbFile smbFile, bool append = false) { return Task.Run(() => new SmbFileOutputStream(smbFile, append) as OutputStream); } } }