|
539 | 539 | path-utils:generate-autosave-name |
540 | 540 | (-> (or/c #f path-string? path-for-some-system?) path?) |
541 | 541 | (filename) |
542 | | - @{Generates a name for an autosave file from @racket[filename].}) |
| 542 | + @{ |
| 543 | + Generates a path for an autosave file based on @racket[filename]. |
| 544 | + |
| 545 | + @index{'path-utils:autosave-dir} |
| 546 | + The value of @racket[(preferences:get 'path-utils:autosave-dir)] |
| 547 | + determines the directory of the resulting path. |
| 548 | + When the preference value is @racket[#f] (the default), |
| 549 | + result will use the same directory as the @racket[filename] |
| 550 | + (or, when @racket[filename] is @racket[#f], the directory determined by |
| 551 | + @racket[(find-system-path 'doc-dir)]). |
| 552 | + Otherwise, when @racket[(preferences:get 'path-utils:autosave-dir)] |
| 553 | + returns a path satisfying @racket[complete-path?] and |
| 554 | + @racket[directory-exists?], the autosave file will be saved in |
| 555 | + that directory. |
| 556 | + A relative @racket[filename] will be resolved based on |
| 557 | + the value of @racket[(current-directory)]. |
| 558 | + |
| 559 | + When @racket[filename] is @racket[#f], the final element of the |
| 560 | + resulting path will be an automatically-generated unique name. |
| 561 | + Otherwise, the final path element will be derived from @racket[filename]. |
| 562 | + When @racket[(preferences:get 'path-utils:autosave-dir)] returns |
| 563 | + @racket[#f], the original file name will be used directly as the base; |
| 564 | + otherwise, base will be the complete path to @racket[filename], |
| 565 | + encoded by replacing each seperator (@litchar{\} on Windows or |
| 566 | + @litchar{/} on Unix or Mac OS) with @litchar{!}. |
| 567 | + This base is transformed into the final path element in a |
| 568 | + platform-specific manner: |
| 569 | + @itemlist[ |
| 570 | + @item{On Unix and Mac OS, a @litchar{#} is added to the start |
| 571 | + and end of the file’s name, then a number is added after the |
| 572 | + ending @litchar{#}, and then one more @litchar{#} is appended |
| 573 | + after the number. |
| 574 | + The number is selected to make the autosave filename unique.} |
| 575 | + @item{On Windows, the file’s extension is replaced with a number |
| 576 | + to make the autosave filename unique.} |
| 577 | + ]}) |
543 | 578 |
|
544 | 579 | (proc-doc/names |
545 | 580 | path-utils:generate-backup-name |
546 | 581 | (path? . -> . path?) |
547 | 582 | (filename) |
548 | | - @{Generates a name for an backup file from @racket[filename].}) |
| 583 | + @{ |
| 584 | + Generates a path for a backup file based on @racket[filename]. |
| 585 | + |
| 586 | + @index{'path-utils:backup-dir} |
| 587 | + The value of @racket[(preferences:get 'path-utils:backup-dir)] |
| 588 | + determines the directory of the resulting path in much the same |
| 589 | + way as @racket[path-utils:generate-autosave-name] responds to |
| 590 | + the preference @racket['path-utils:autosave-dir]: |
| 591 | + when the value is @racket[#f] (the default), the directory of |
| 592 | + @racket[filename] is used, and otherwise the directory from the |
| 593 | + preference is used. |
| 594 | + |
| 595 | + The final element of the resulting path is generated from |
| 596 | + @racket[filename] in a platform-specific manner: |
| 597 | + @itemlist[ |
| 598 | + @item{On Unix and Mac OS, a @litchar{~} is added to the end |
| 599 | + of the file’s name.} |
| 600 | + @item{On Windows, the file’s extension is replaced |
| 601 | + with @litchar{.bak}.}] |
| 602 | + In either case, when @racket[(preferences:get 'path-utils:backup-dir)] |
| 603 | + returns a non-false value, the result of the above transformation |
| 604 | + is combined with the complete path of @racket[filename], |
| 605 | + encoded by replacing seperators with @litchar{!} as with |
| 606 | + @racket[path-utils:generate-autosave-name], to form the final |
| 607 | + path element. |
| 608 | + }) |
549 | 609 |
|
550 | 610 | (parameter-doc |
551 | 611 | finder:dialog-parent-parameter |
|
0 commit comments