Skip to content

Commit 41854a3

Browse files
committed
Work on queue functionality
1 parent e47f2fd commit 41854a3

File tree

2 files changed

+15
-41
lines changed

2 files changed

+15
-41
lines changed

SmartImage 3/App/Integration.cs

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public static bool ReadClipboard(out string str)
316316
return b;
317317
}
318318

319-
public static string[] OpenFile(OFN f = 0)
319+
public static string[] OpenFile(OFN flags = 0)
320320
{
321321
// Span<char> p1 = stackalloc char[1024];
322322
// Span<char> p2 = stackalloc char[512];
@@ -337,80 +337,54 @@ public static string[] OpenFile(OFN f = 0)
337337

338338
lpstrInitialDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures),
339339
lpstrTitle = "Pick an image",
340-
Flags = (int) f
340+
Flags = (int) flags
341341
};
342342

343343
// ofn.nMaxFile = ofn.lpstrFile.Length;
344344
ofn.nMaxFile = ss;
345345
ofn.nMaxFileTitle = ss;
346346
// ofn.nMaxFileTitle = ofn.lpstrFileTitle.Length;
347347

348-
string rgz;
349-
350348
bool ok = Native.GetOpenFileName(ref ofn);
351349

352-
List<string> files = new List<string>();
350+
var files = new List<string>();
353351

354352
if (!ok) {
355353
goto ret;
356354
}
357355

358356
var pd = Marshal.PtrToStringAuto((nint) p1);
359357

360-
if (!(f.HasFlag(OFN.OFN_ALLOWMULTISELECT)) /*!Directory.Exists(pd)&&File.Exists(pd)*/) {
361-
files = new List<string>() { pd };
358+
if (!(flags.HasFlag(OFN.OFN_ALLOWMULTISELECT)) /*!Directory.Exists(pd)&&File.Exists(pd)*/) {
359+
files.Add(pd);
362360
goto ret;
363361
}
364362

365-
var ofs = (ofn.nFileOffset*2);
363+
var ofs = (ofn.nFileOffset * 2);
366364
var ptr1 = ((byte*) p1 + ofs);
367365

368366
while (true) {
369-
// var _dir1 = Encoding.Unicode.GetString(ptr1, ofs+1);
370367

371-
var _dir1 = Marshal.PtrToStringAuto((nint)ptr1);
372-
if (string.IsNullOrWhiteSpace(_dir1)) {
368+
var file = Marshal.PtrToStringAuto((nint) ptr1);
369+
370+
if (string.IsNullOrWhiteSpace(file)) {
373371
break;
374372
}
375373

376-
var ff = _dir1.Split('\0').Select(s => Path.Combine(pd, s)).ToArray();
377-
files.AddRange(ff);
378-
ptr1 += (_dir1.Length*2) + 2;
374+
ptr1 += (file.Length * 2) + 2;
375+
file = Path.Combine(pd, file);
376+
files.Add(file);
379377

380-
if ((*ptr1 ==0 && ptr1[1] == 0)) {
378+
// Last filename is double NULL-terminated
379+
if ((*ptr1 == 0 && ptr1[1] == 0)) {
381380
break;
382381
}
383382
}
384383

385-
// Debug.WriteLine($"{_dir1} {sz1}");
386-
/*rgz = ok ? new string(ofn.lpstrFile, 0, ) : null;
387-
388-
unsafe {
389-
fixed (char* p = rgz) {
390-
sbyte* pp = (sbyte*) p;
391-
392-
int i = 0;
393-
394-
while (*pp++ != 0) { ++i; }
395-
396-
Debug.WriteLine($"{i} {(nint) pp:X}");
397-
}
398-
399-
}*/
400384
ret:
401385
return files.ToArray();
402386

403387
}
404388
}
405389

406-
private static unsafe int _count(int ss, sbyte* p1)
407-
{
408-
int i;
409-
410-
for (i = 0; i < ss; i++) {
411-
if (p1[i] == 0 && p1[i + 1] == 0) { }
412-
}
413-
414-
return i;
415-
}
416390
}

SmartImage 3/Mode/Shell/ShellMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public ShellMode(string[] args)
346346
*/
347347

348348
// m_cbCallbackTok = Application.MainLoop.AddTimeout(TimeoutTimeSpan, ClipboardCallback);
349-
// UseClipboard = true;
349+
UseClipboard = Config.Clipboard;
350350

351351
m_clipboard = new List<ustring>();
352352

0 commit comments

Comments
 (0)