Git storage: replaces colons with equal in picture offset

I found another place where we had colons in file names...

This fixes a small cut and paste error in an error message as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-21 06:12:33 -07:00
parent 217c6462f5
commit 9d8b05f47e
2 changed files with 14 additions and 12 deletions

View file

@ -1262,7 +1262,10 @@ static int nonunique_length(const char *str)
*
* - It's a dive directory. The name will be of the form
*
* [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex]
* [[yyyy-]mm-]nn-ddd-hh=mm=ss[~hex]
*
* (older versions had this as [[yyyy-]mm-]nn-ddd-hh:mm:ss[~hex]
* but that faile on Windows)
*
* which describes the date and time of a dive (yyyy and mm
* are optional, and may be encoded in the path leading up to
@ -1272,10 +1275,8 @@ static int nonunique_length(const char *str)
*
* - It's some random non-dive-data directory.
*
* Subsurface doesn't create these yet, but maybe we'll encode
* pictures etc. If it doesn't match the above patterns, we'll
* ignore them for dive loading purposes, and not even recurse
* into them.
* If it doesn't match the above patterns, we'll ignore them
* for dive loading purposes, and not even recurse into them.
*/
static int walk_tree_directory(const char *root, const git_tree_entry *entry)
{
@ -1427,12 +1428,13 @@ static int parse_picture_entry(git_repository *repo, const git_tree_entry *entry
char sign;
/*
* The format of the picture name files is just the offset
* within the dive in form [[+-]hh:mm:ss, possibly followed
* by a hash to make the filename unique (which we can just
* ignore).
* The format of the picture name files is just the offset within
* the dive in form [[+-]hh=mm=ss (previously [[+-]hh:mm:ss, but
* that didn't work on Windows), possibly followed by a hash to
* make the filename unique (which we can just ignore).
*/
if (sscanf(name, "%c%d:%d:%d", &sign, &hh, &mm, &ss) != 4)
if (sscanf(name, "%c%d:%d:%d", &sign, &hh, &mm, &ss) != 4 &&
sscanf(name, "%c%d=%d=%d", &sign, &hh, &mm, &ss) != 4)
return report_error("Unknown file name %s", name);
offset = ss + 60*(mm + 60*hh);
if (sign == '-')
@ -1440,7 +1442,7 @@ static int parse_picture_entry(git_repository *repo, const git_tree_entry *entry
blob = git_tree_entry_blob(repo, entry);
if (!blob)
return report_error("Unable to read trip file");
return report_error("Unable to read picture file");
pic = alloc_picture();
pic->offset.seconds = offset;

View file

@ -608,7 +608,7 @@ static int save_one_picture(git_repository *repo, struct dir *dir, struct pictur
/* Use full hh:mm:ss format to make it all sort nicely */
h = offset / 3600;
offset -= h *3600;
return blob_insert(repo, dir, &buf, "%c%02u:%02u:%02u",
return blob_insert(repo, dir, &buf, "%c%02u=%02u=%02u",
sign, h, FRACTION(offset, 60));
}