Skip to content

Commit 794c5d9

Browse files
committed
Add file extension of single FilesContent
closes #85
1 parent 6946179 commit 794c5d9

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

PasteIntoFile/ClipboardContents.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,22 @@ public List<string> FileList {
669669
}
670670
public string FileListString => string.Join("\n", FileList);
671671

672-
public override string[] Extensions => new[] { "zip", "m3u", "files", "txt" };
672+
public override string[] Extensions {
673+
get {
674+
var extensions = new[] { "zip", "m3u", "files", "txt" };
675+
if (SingleFileExtension != null) extensions = extensions.Prepend(SingleFileExtension).ToArray();
676+
return extensions;
677+
}
678+
}
679+
680+
private string SingleFileExtension => Files.Count == 1 ? NormalizeExtension(Path.GetExtension(Files[0]).TrimStart('.')) : null;
681+
673682
public override void SaveAs(string path, string extension, bool append = false) {
683+
if (SingleFileExtension != null && SingleFileExtension == NormalizeExtension(extension)) {
684+
if (append) throw new AppendNotSupportedException();
685+
File.Copy(Files[0], path, overwrite: true);
686+
return;
687+
}
674688
switch (NormalizeExtension(extension)) {
675689
case "zip":
676690
// TODO: since zipping can take a while depending on file size, this should show a progress to the user

0 commit comments

Comments
 (0)