Module docsettings
This module is responsible for reading and writing metadata.lua
files
in the so-called sidecar directory
(Wikipedia definition).
Functions
DocSettings:getSidecarDir (doc_path) | Returns path to sidecar directory (filename.sdr ). |
DocSettings:getSidecarFile (doc_path) | Returns path to metadata.lua file. |
DocSettings:hasSidecarFile (doc_path, no_legacy) | Returns path of metadata.lua file if it exists, or nil. |
DocSettings:findCoverFile (doc_path) | Returns path to book custom cover file if it exists, or nil. |
DocSettings:open (doc_path) | Opens a document's individual settings (font, margin, dictionary, etc.) |
DocSettings:flush (data, no_cover) | Serializes settings and writes them to metadata.lua . |
DocSettings:purge (sidecar_to_keep) | Purges (removes) sidecar directory. |
DocSettings:removeSidecarDir (doc_path, sidecar_dir) | Removes empty sidecar dir. |
DocSettings:updateLocation (doc_path, new_doc_path, copy) | Updates sdr location for file rename/copy/move/delete operations. |
Functions
- DocSettings:getSidecarDir (doc_path)
-
Returns path to sidecar directory (
filename.sdr
). Sidecar directory is the file without last suffix.Parameters:
- doc_path
string
path to the document (e.g.,
/foo/bar.pdf
)
Returns:
-
string
path to the sidecar directory (e.g.,
/foo/bar.sdr
) - doc_path
string
path to the document (e.g.,
- DocSettings:getSidecarFile (doc_path)
-
Returns path to
metadata.lua
file.Parameters:
- doc_path
string
path to the document (e.g.,
/foo/bar.pdf
)
Returns:
-
string
path to
/foo/bar.sdr/metadata.lua
file - doc_path
string
path to the document (e.g.,
- DocSettings:hasSidecarFile (doc_path, no_legacy)
-
Returns path of
metadata.lua
file if it exists, or nil.Parameters:
- doc_path
string
path to the document (e.g.,
/foo/bar.pdf
) - no_legacy bool set to true to skip check of the legacy history file
Returns:
- doc_path
string
path to the document (e.g.,
- DocSettings:findCoverFile (doc_path)
-
Returns path to book custom cover file if it exists, or nil.
Parameters:
- doc_path
- DocSettings:open (doc_path)
-
Opens a document's individual settings (font, margin, dictionary, etc.)
Parameters:
- doc_path
string
path to the document (e.g.,
/foo/bar.pdf
)
Returns:
-
DocSettings
object
- doc_path
string
path to the document (e.g.,
- DocSettings:flush (data, no_cover)
-
Serializes settings and writes them to
metadata.lua
.Parameters:
- data
- no_cover Depending on the settings, doc_settings are saved to the book folder or to koreader/docsettings folder. The latter is also a fallback for read-only book storage.
- DocSettings:purge (sidecar_to_keep)
-
Purges (removes) sidecar directory.
Parameters:
- sidecar_to_keep Remove any of the old ones we may consider as candidates in DocSettings open()
- DocSettings:removeSidecarDir (doc_path, sidecar_dir)
-
Removes empty sidecar dir.
Parameters:
- doc_path
- sidecar_dir
- DocSettings:updateLocation (doc_path, new_doc_path, copy)
-
Updates sdr location for file rename/copy/move/delete operations.
Parameters:
- doc_path
- new_doc_path
- copy