Mercurial > geeqie.yaz
diff src/filedata.c @ 914:9427c91951e8
basic infrastructure for early error and dangerous operations checking
it needs more work
author | nadvornik |
---|---|
date | Tue, 22 Jul 2008 21:46:08 +0000 |
parents | 2f9edd196dca |
children | 8cca92a61c6c |
line wrap: on
line diff
--- a/src/filedata.c Tue Jul 22 18:27:12 2008 +0000 +++ b/src/filedata.c Tue Jul 22 21:46:08 2008 +0000 @@ -1621,12 +1621,54 @@ /* * check dest paths - dest image exists, etc. - * returns FIXME * it should detect all possible problems with the planned operation + * FIXME: add more tests */ + +gint file_data_check_ci_dest(FileData *fd) +{ + gint ret = CHANGE_OK; + + g_assert(fd->change); + + if (fd->change->dest && + strcmp(fd->change->dest, fd->path) != 0 && + isname(fd->change->dest)) + { + ret |= CHANGE_DEST_EXISTS; + DEBUG_1("Change checked: destination exists: %s -> %s", fd->path, fd->change->dest); + } + + if (!access_file(fd->path, R_OK)) + { + ret |= CHANGE_NO_PERM; + DEBUG_1("Change checked: no read permission: %s", fd->path); + } + + fd->change->error = ret; + if (ret == 0) DEBUG_1("Change checked: OK: %s", fd->path); + + return ret; +} + gint file_data_sc_check_ci_dest(FileData *fd) { + GList *work; + int ret; + + ret = file_data_check_ci_dest(fd); + + work = fd->sidecar_files; + while (work) + { + FileData *sfd = work->data; + + ret |= file_data_check_ci_dest(sfd); + work = work->next; + } + + return ret; }