comparison 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
comparison
equal deleted inserted replaced
913:2f9edd196dca 914:9427c91951e8
1619 } 1619 }
1620 1620
1621 1621
1622 /* 1622 /*
1623 * check dest paths - dest image exists, etc. 1623 * check dest paths - dest image exists, etc.
1624 * returns FIXME
1625 * it should detect all possible problems with the planned operation 1624 * it should detect all possible problems with the planned operation
1625 * FIXME: add more tests
1626 */ 1626 */
1627
1628 gint file_data_check_ci_dest(FileData *fd)
1629 {
1630 gint ret = CHANGE_OK;
1631
1632 g_assert(fd->change);
1633
1634 if (fd->change->dest &&
1635 strcmp(fd->change->dest, fd->path) != 0 &&
1636 isname(fd->change->dest))
1637 {
1638 ret |= CHANGE_DEST_EXISTS;
1639 DEBUG_1("Change checked: destination exists: %s -> %s", fd->path, fd->change->dest);
1640 }
1641
1642 if (!access_file(fd->path, R_OK))
1643 {
1644 ret |= CHANGE_NO_PERM;
1645 DEBUG_1("Change checked: no read permission: %s", fd->path);
1646 }
1647
1648 fd->change->error = ret;
1649 if (ret == 0) DEBUG_1("Change checked: OK: %s", fd->path);
1650
1651 return ret;
1652 }
1653
1627 1654
1628 gint file_data_sc_check_ci_dest(FileData *fd) 1655 gint file_data_sc_check_ci_dest(FileData *fd)
1629 { 1656 {
1657 GList *work;
1658 int ret;
1659
1660 ret = file_data_check_ci_dest(fd);
1661
1662 work = fd->sidecar_files;
1663 while (work)
1664 {
1665 FileData *sfd = work->data;
1666
1667 ret |= file_data_check_ci_dest(sfd);
1668 work = work->next;
1669 }
1670
1671 return ret;
1630 } 1672 }
1631 1673
1632 1674
1633 1675
1634 1676