protected override void GetItem(string path) { if (PathIsDrive(path)) { WriteItemObject(PSDriveInfo, path, true); } try { string parsedPath = ParsePath(path, false); ZipFileArchive.ZipFileInfo fileInfo = GetPathCaseInsensitive(parsedPath); ZipFileItem zi = new ZipFileItem(GetFileOrDirname(fileInfo.Name), fileInfo.LastModFileDateTime, fileInfo.FolderFlag ? "Directory" : "File"); WriteItemObject(zi, fixRootPath(fileInfo.Name).Replace("/", "\\"), fileInfo.FolderFlag); } catch { } try { string parsedPath = ParsePath(path, true); ZipFileArchive.ZipFileInfo fileInfo = GetPathCaseInsensitive(parsedPath); ZipFileItem zi = new ZipFileItem(GetFileOrDirname(fileInfo.Name), fileInfo.LastModFileDateTime, fileInfo.FolderFlag ? "Directory" : "File"); WriteItemObject(zi, fixRootPath(fileInfo.Name).Replace("/", "\\"), fileInfo.FolderFlag); } catch { } }
protected override bool ItemExists(string path) { if (String.IsNullOrEmpty(path)) { WriteError(new ErrorRecord(new ArgumentException("path"), "NoPath", ErrorCategory.InvalidArgument, path)); return(false); } if (PathIsDrive(path)) { return(true); } try { string fileToFind = ParsePath(path, true); ZipFileArchive.ZipFileInfo info = GetPathCaseInsensitive(fileToFind); return(true); } catch { } try { string fileToFind = ParsePath(path, false); ZipFileArchive.ZipFileInfo info = GetPathCaseInsensitive(fileToFind); return(true); } catch { return(false); } }
protected override void NewItem(string path, string type, object newItemValue) { ZipFileArchive.ZipFileInfo fileInfo = ZipDrive.Archive.AddFile(ParsePath(path, false), ZipFileArchive.CompressionMethodEnum.Deflated, ZipFileArchive.DeflateOptionEnum.Normal); }