mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-14 12:19:08 +00:00
Compare commits
6 Commits
copilot/fi
...
copilot/fi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c97f924055 | ||
![]() |
67168e51aa | ||
![]() |
21a3dd3d4b | ||
![]() |
ebb48366a0 | ||
![]() |
e12bb2201b | ||
![]() |
14a5bea926 |
Submodule QuickLook.Common updated: 8978dce92c...21cbdf4cfe
@@ -61,8 +61,8 @@ public class AppImageReader
|
||||
|
||||
public AppImageReader(string path)
|
||||
{
|
||||
using FileStream fs = File.OpenRead(path);
|
||||
Open(fs);
|
||||
using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
Open(fileStream);
|
||||
}
|
||||
|
||||
private void Open(Stream stream)
|
||||
|
@@ -29,7 +29,7 @@ internal static class WgtParser
|
||||
{
|
||||
public static WgtInfo Parse(string path)
|
||||
{
|
||||
using var fileStream = File.OpenRead(path);
|
||||
using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Read);
|
||||
var manifestEntry = zipArchive.GetEntry("manifest.json");
|
||||
|
||||
|
@@ -134,14 +134,14 @@ public partial class ArchiveInfoPanel : UserControl, IDisposable, INotifyPropert
|
||||
|
||||
private void LoadItemsFromArchive(string path)
|
||||
{
|
||||
using var stream = File.OpenRead(path);
|
||||
using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
|
||||
// ReaderFactory is slow... so limit its usage
|
||||
string[] useReader = [".tar.gz", ".tgz", ".tar.bz2", ".tar.lz", ".tar.xz"];
|
||||
|
||||
if (useReader.Any(path.ToLower().EndsWith))
|
||||
{
|
||||
var reader = ReaderFactory.Open(stream, new ChardetReaderOptions());
|
||||
var reader = ReaderFactory.Open(fileStream, new ChardetReaderOptions());
|
||||
|
||||
_type = reader.ArchiveType.ToString();
|
||||
|
||||
@@ -149,13 +149,13 @@ public partial class ArchiveInfoPanel : UserControl, IDisposable, INotifyPropert
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
LoadPercent = 100d * stream.Position / stream.Length;
|
||||
LoadPercent = 100d * fileStream.Position / fileStream.Length;
|
||||
ProcessByLevel(reader.Entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var archive = ArchiveFactory.Open(stream, new ChardetReaderOptions());
|
||||
var archive = ArchiveFactory.Open(fileStream, new ChardetReaderOptions());
|
||||
|
||||
_type = archive.Type.ToString();
|
||||
|
||||
@@ -163,7 +163,7 @@ public partial class ArchiveInfoPanel : UserControl, IDisposable, INotifyPropert
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
LoadPercent = 100d * stream.Position / stream.Length;
|
||||
LoadPercent = 100d * fileStream.Position / fileStream.Length;
|
||||
ProcessByLevel(entry);
|
||||
}
|
||||
}
|
||||
|
@@ -40,12 +40,19 @@ internal unsafe static class FreeTypeApi
|
||||
|
||||
error = FT_New_Face(lib, (byte*)Marshal.StringToHGlobalAnsi(path), IntPtr.Zero, &face);
|
||||
|
||||
try
|
||||
{
|
||||
if (error == FT_Error.FT_Err_Ok)
|
||||
{
|
||||
var familyName = Marshal.PtrToStringAnsi((nint)face->family_name);
|
||||
return familyName;
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
FT_Done_Face(face);
|
||||
FT_Done_FreeType(lib);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -149,11 +149,11 @@ public class WebfontPanel : WebpagePanel
|
||||
}
|
||||
else
|
||||
{
|
||||
var localPath = _fallbackPath + requestedUri.AbsolutePath.Replace('/', '\\');
|
||||
var localPath = _fallbackPath + Uri.UnescapeDataString(requestedUri.AbsolutePath).Replace('/', '\\');
|
||||
|
||||
if (File.Exists(localPath))
|
||||
{
|
||||
var fileStream = File.OpenRead(localPath);
|
||||
var fileStream = new FileStream(localPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var response = _webView.CoreWebView2.Environment.CreateWebResourceResponse(
|
||||
fileStream, 200, "OK", MimeTypes.GetContentType());
|
||||
args.Response = response;
|
||||
|
@@ -210,7 +210,7 @@ public class WebpagePanel : UserControl
|
||||
if (File.Exists(fallbackFilePath))
|
||||
{
|
||||
// Serve the file from the fallback directory
|
||||
var fileStream = File.OpenRead(fallbackFilePath);
|
||||
var fileStream = new FileStream(fallbackFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var response = _webView.CoreWebView2.Environment.CreateWebResourceResponse(
|
||||
fileStream, 200, "OK", "Content-Type: application/octet-stream");
|
||||
args.Response = response;
|
||||
|
@@ -27,7 +27,7 @@ internal static class LottieExtractor
|
||||
{
|
||||
public static string GetJsonContent(string path)
|
||||
{
|
||||
using var fileStream = File.OpenRead(path);
|
||||
using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Read);
|
||||
|
||||
var manifestEntry = zipArchive.GetEntry("manifest.json");
|
||||
|
@@ -130,11 +130,11 @@ public class SvgImagePanel : WebpagePanel, IWebImagePanel
|
||||
}
|
||||
else
|
||||
{
|
||||
var localPath = _fallbackPath + requestedUri.AbsolutePath.Replace('/', '\\');
|
||||
var localPath = _fallbackPath + Uri.UnescapeDataString(requestedUri.AbsolutePath).Replace('/', '\\');
|
||||
|
||||
if (File.Exists(localPath))
|
||||
{
|
||||
var fileStream = File.OpenRead(localPath);
|
||||
var fileStream = new FileStream(localPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var response = _webView.CoreWebView2.Environment.CreateWebResourceResponse(
|
||||
fileStream, 200, "OK", MimeTypes.GetContentTypeHeader());
|
||||
args.Response = response;
|
||||
@@ -149,7 +149,7 @@ public class SvgImagePanel : WebpagePanel, IWebImagePanel
|
||||
{
|
||||
if (File.Exists(localPath))
|
||||
{
|
||||
var fileStream = File.OpenRead(localPath);
|
||||
var fileStream = new FileStream(localPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var response = _webView.CoreWebView2.Environment.CreateWebResourceResponse(
|
||||
fileStream, 200, "OK",
|
||||
$"""
|
||||
|
@@ -124,11 +124,11 @@ public class MarkdownPanel : WebpagePanel
|
||||
}
|
||||
else
|
||||
{
|
||||
var localPath = _fallbackPath + requestedUri.AbsolutePath.Replace('/', '\\');
|
||||
var localPath = _fallbackPath + Uri.UnescapeDataString(requestedUri.AbsolutePath).Replace('/', '\\');
|
||||
|
||||
if (File.Exists(localPath))
|
||||
{
|
||||
var fileStream = File.OpenRead(localPath);
|
||||
var fileStream = new FileStream(localPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var response = _webView.CoreWebView2.Environment.CreateWebResourceResponse(
|
||||
fileStream, 200, "OK", MimeTypes.GetContentType());
|
||||
args.Response = response;
|
||||
|
@@ -34,6 +34,7 @@ public class Plugin : IViewer
|
||||
".xls", ".xlsx", ".xlsm", ".xlsb", ".ods",
|
||||
".ppt", ".pptx", ".odp",
|
||||
".vsd", ".vsdx",
|
||||
".ofd",
|
||||
];
|
||||
|
||||
private PreviewPanel _panel;
|
||||
|
@@ -69,9 +69,9 @@ public class Plugin : IViewer
|
||||
if (path.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var rtfBox = new RichTextBox();
|
||||
using FileStream fs = File.OpenRead(path);
|
||||
using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
rtfBox.Background = new SolidColorBrush(Colors.Transparent);
|
||||
rtfBox.Selection.Load(fs, DataFormats.Rtf);
|
||||
rtfBox.Selection.Load(fileStream, DataFormats.Rtf);
|
||||
rtfBox.IsReadOnly = true;
|
||||
rtfBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
rtfBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
|
@@ -187,8 +187,8 @@ public class HighlightingThemeManager
|
||||
{
|
||||
Debug.WriteLine(file);
|
||||
var ext = Path.GetFileNameWithoutExtension(file);
|
||||
using Stream s = File.OpenRead(Path.GetFullPath(file));
|
||||
using var reader = new XmlTextReader(s);
|
||||
using var fileStream = new FileStream(Path.GetFullPath(file), FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var reader = new XmlTextReader(fileStream);
|
||||
var xshd = HighlightingLoader.LoadXshd(reader);
|
||||
var highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
|
||||
if (xshd.Extensions.Count > 0)
|
||||
|
@@ -81,8 +81,7 @@ public class BackgroundVisualHost : FrameworkElement
|
||||
private readonly CreateContentFunction _createContent;
|
||||
private readonly Action _invalidateMeasure;
|
||||
|
||||
private readonly AutoResetEvent _sync =
|
||||
new AutoResetEvent(false);
|
||||
private readonly AutoResetEvent _sync = new(false);
|
||||
|
||||
public ThreadedVisualHelper(
|
||||
CreateContentFunction createContent,
|
||||
@@ -125,15 +124,9 @@ public class BackgroundVisualHost : FrameworkElement
|
||||
}
|
||||
}
|
||||
|
||||
#region Private Fields
|
||||
|
||||
public ThreadedVisualHelper ThreadedHelper;
|
||||
private HostVisual _hostVisual;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region IsContentShowingProperty
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the IsContentShowing dependency property.
|
||||
/// </summary>
|
||||
@@ -163,10 +156,6 @@ public class BackgroundVisualHost : FrameworkElement
|
||||
bvh.HideContentHelper();
|
||||
}
|
||||
|
||||
#endregion IsContentShowingProperty
|
||||
|
||||
#region CreateContent Property
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the CreateContent dependency property.
|
||||
/// </summary>
|
||||
@@ -196,6 +185,4 @@ public class BackgroundVisualHost : FrameworkElement
|
||||
bvh.CreateContentHelper();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion CreateContent Property
|
||||
}
|
||||
|
@@ -58,50 +58,16 @@ public partial class InfoPanel : UserControl
|
||||
Dispatcher.BeginInvoke(new Action(() => image.Source = source));
|
||||
});
|
||||
|
||||
string name;
|
||||
try
|
||||
{
|
||||
name = Path.GetFileName(path);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// Handle invalid path characters gracefully
|
||||
name = path;
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
// Handle path too long scenarios
|
||||
name = path;
|
||||
}
|
||||
var name = Path.GetFileName(path);
|
||||
filename.Text = string.IsNullOrEmpty(name) ? path : name;
|
||||
|
||||
try
|
||||
{
|
||||
var last = File.GetLastWriteTime(path);
|
||||
modDate.Text = string.Format(TranslationHelper.Get("InfoPanel_LastModified"),
|
||||
last.ToString(CultureInfo.CurrentCulture));
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// Handle invalid path characters gracefully
|
||||
modDate.Text = TranslationHelper.Get("InfoPanel_LastModified_Unavailable") ?? "Last modified: Unavailable";
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// Handle access denied scenarios
|
||||
modDate.Text = TranslationHelper.Get("InfoPanel_LastModified_Unavailable") ?? "Last modified: Unavailable";
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
// Handle path too long scenarios
|
||||
modDate.Text = TranslationHelper.Get("InfoPanel_LastModified_Unavailable") ?? "Last modified: Unavailable";
|
||||
}
|
||||
|
||||
Stop = false;
|
||||
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
@@ -151,22 +117,6 @@ public partial class InfoPanel : UserControl
|
||||
$"{totalSizeL.ToPrettySize(2)} {t}";
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// Handle invalid path characters gracefully
|
||||
Dispatcher.Invoke(() => { totalSize.Text = "Size: Unavailable"; });
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// Handle access denied scenarios
|
||||
Dispatcher.Invoke(() => { totalSize.Text = "Size: Unavailable"; });
|
||||
}
|
||||
catch (PathTooLongException)
|
||||
{
|
||||
// Handle path too long scenarios
|
||||
Dispatcher.Invoke(() => { totalSize.Text = "Size: Unavailable"; });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user