• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

CLI interface to medialist (fossil mirror)


Commit MetaInfo

修訂b9ad10af01ca9d1a3590bf0a634fdd5447138c23 (tree)
時間2023-04-04 15:08:37
作者mio <stigma@disr...>
Commitermio

Log Message

Change ml_open_list (nothrow) to call ml_open_list (throw).
Change mentions of version 0.2.0/0.4.0 to 0.4.0 to match medialist-cli.

FossilOrigin-Name: edaab5e4722276e835dc261bb380bd3ef5032450316cd30ee68b48bcd957675d

Change Summary

差異

--- a/medialist.d
+++ b/medialist.d
@@ -32,9 +32,9 @@ import std.string;
3232 ///
3333 /// Enumeration string containing the verison of MediaList.
3434 ///
35-/// Since: 0.2.0
35+/// Since: 0.4.0
3636 ///
37-enum string MediaListVersion = "0.2.0-dev";
37+enum string MediaListVersion = "0.4.0-dev";
3838
3939 ///
4040 /// Enumeration array of int containing the version of MediaList.
@@ -45,9 +45,9 @@ enum string MediaListVersion = "0.2.0-dev";
4545 /// API. Patch versions represent compile-time fixes. Minor versions represent
4646 /// all other changes.
4747 ///
48-/// Since: 0.2.0
48+/// Since: 0.4.0
4949 ////
50-enum int[3] MediaListVersionA = [0, 2, 0];
50+enum int[3] MediaListVersionA = [0, 4, 0];
5151
5252 ///
5353 /// The main structure for interacting with a list in `medialist`.
@@ -380,70 +380,30 @@ MediaList* ml_open_list(string filePath)
380380 ///
381381 /// Returns: A GC-allocated MediaList structure.
382382 ///
383-/// Throws:
384-/// - ErrnoException if the file could not be opened, there was an
385-/// error writing to file, or if there was an error closing the
386-/// file.
387-///
388383 MediaList* ml_open_list(string filePath, out MLError error) nothrow
389384 {
390385 import std.exception : ErrnoException;
391386 import core.stdc.errno;
392387
393- string listName = stripExtension(baseName(filePath));
394- MediaList* ml = new MediaList(filePath, listName);
388+ MediaList* list;
395389
396- if (false == exists(filePath))
397- {
398- ml.isOpen = true;
399- scope (exit)
400- ml.isOpen = false;
401-
402- try
403- {
404- File f = File(filePath, "w+");
405-
406- f.writeln("# This file is in the mTSV format.");
407- f.writeln("# For more information about this format,");
408- f.writeln("# please view the website:");
409- f.writeln("# http://yume-neru.neocities.org/p/mtsv.html");
410- f.writeln("title\tprogress\tstatus\tstart_date\tend_date\tlast_updated");
411- }
412- catch (ErrnoException ee)
413- {
414- static if (__VERSION__ < 2088L)
415- {
416- switch (errno)
417- {
418- case EACCES:
419- error = MLError.permissionError;
420- return null;
421- default:
422- error = MLError.unspecifiedError;
423- return null;
424- }
425- }
426- else
427- {
428- switch (ee.errno())
429- {
430- case EACCES:
431- error = MLError.permissionError;
432- return null;
433- default:
434- error = MLError.unspecifiedError;
435- return null;
436- }
437- }
438- }
439- catch (Exception e)
390+ try {
391+ list = ml_open_list(filePath);
392+ } catch (ErrnoException ee) {
393+ switch (errno)
440394 {
395+ case EACCES:
396+ error = MLError.permissionError;
397+ break;
398+ default:
441399 error = MLError.unspecifiedError;
442- return null;
400+ break;
443401 }
402+ } catch (Exception e) {
403+ error = MLError.unspecifiedError;
444404 }
445405
446- return ml;
406+ return list;
447407 }
448408
449409 ///
@@ -1367,7 +1327,7 @@ private void _ml_delete(MediaList* list, string[] args)
13671327 throw new MLException(MLError.fileAlreadyOpen);
13681328
13691329 if (0 == args.length) {
1370- // NOTE: This will be removed in a version after 0.2.0.
1330+ // NOTE: This will be removed in a version after 0.4.0.
13711331 remove(list.filePath);
13721332 return;
13731333 }