group DCF files that share a file number (closes #3)
Files in one DCF directory that share a file number are one file group, as section 4.3.2.2 of the specification says. `Directory.FileGroups` lists them, each with its numbers, its members and its primary member. A lone file is a group of one. A group reports its member count and total size. Section 6.2.1.3 gives a DCF basic file priority over a DCF extended image file. It says nothing about a DCF optional file, so ranking every `JPG` first is a choice. A `THM` comes last. `isImageFile` now accepts `.tif`, so a `TIF` counts as an image. `Store.Images`, `Store.Videos` and the totals still count each file on its own. Model: opus-5-5
This commit is contained in:
1 parent
2c61b85a53
commit
caa73fbcca
7 files changed
+388
-20
No files matched your search
@@ -109,14 +109,16 @@ All the code is in the `pkg/dcf` package. The repo has no commands.
|
||||
each one.
|
||||
- `helpers.go` finds the mount points that hold a DCF store.
|
||||
- `parse.go` reads one DCF store through an `fs.FS` rooted at its mount point.
|
||||
- `filegroup.go` sorts the files of one DCF directory into file groups.
|
||||
|
||||
The main types are:
|
||||
|
||||
- `Store` is one DCF store on one mounted filesystem.
|
||||
- `Directory` is one DCF directory. It has a directory number, a name and the
|
||||
objects inside it.
|
||||
- `Directory` is one DCF directory. It has a directory number, a name, the
|
||||
objects inside it and their file groups.
|
||||
- `Object` is one file in a store. A file in a DCF directory also has a
|
||||
directory number and a file number.
|
||||
- `FileGroup` is one file group in a DCF directory.
|
||||
- `Image` and `Video` embed `Object`. The file extension decides which one a
|
||||
file becomes. A file with any other extension, such as a `THM` thumbnail, is
|
||||
neither.
|
||||
@@ -149,11 +151,37 @@ The naming rules do not apply under `PRIVATE/M4ROOT`. The images and videos
|
||||
there are in `Store.Images` and `Store.Videos`, and their DCF numbers are 0.
|
||||
`dcf` skips any symlink there.
|
||||
|
||||
A file group is made of the DCF files in one DCF directory that share a file
|
||||
number. The specification calls it a DCF object. A RAW file and its JPEG form a
|
||||
file group, and so do a video and its `THM` thumbnail.
|
||||
|
||||
- The first four characters and the extension can differ within a group.
|
||||
- A DCF file that shares its number with no other file is a group of one.
|
||||
- Files in different DCF directories are never in the same group.
|
||||
- Only DCF files are grouped. Files in `Store.NonConforming` and under
|
||||
`PRIVATE/M4ROOT` are in no group.
|
||||
|
||||
`Directory.FileGroups` lists the groups in file number order. Each `FileGroup`
|
||||
has:
|
||||
|
||||
- `DirectoryNumber` and `FileNumber`
|
||||
- `Members`, which is every file in the group
|
||||
- `Primary`, which is the member that stands for the whole group
|
||||
- `MembersCount`, which returns the number of members
|
||||
- `TotalSize`, which returns the total size of the members in bytes
|
||||
|
||||
The primary member is the first of these that the group holds:
|
||||
|
||||
1. a `JPG` file
|
||||
2. any other file in `Store.Images`
|
||||
3. a file in `Store.Videos`
|
||||
4. any other file except a `THM`
|
||||
5. a `THM`
|
||||
|
||||
`Store.Images` and `Store.Videos` list each file on its own, whatever its group.
|
||||
|
||||
## TODO
|
||||
|
||||
- Handle DCF file groups, where multiple objects share the same index number.
|
||||
`dcf` does not handle these yet. If you need this, send me a link to a zip or
|
||||
tar of a memory card that uses them, and I'll see what I can do.
|
||||
- Take a `context.Context` to cancel the walk of a store.
|
||||
- Return a plain slice from `GetDCFStores`, not a pointer to one.
|
||||
- Copy files off a card, and verify each copy against its SHA256 hash.
|
||||
|
||||
Reference in new issue
Block a user