4
4
* Copyright (C) Philippe Rouquier 2007-2008 <bonfire-app@wanadoo.fr>
6
* brasero is free software.
8
* You may redistribute it and/or modify it under the terms of the
9
* GNU General Public License, as published by the Free Software
10
* Foundation; either version 2 of the License, or (at your option)
6
* Brasero is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
13
11
* brasero is distributed in the hope that it will be useful,
14
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
444
447
/* the + 1 is for the separator */
445
escaped_name = g_uri_escape_string (BRASERO_FILE_NODE_NAME (node), NULL, TRUE);
448
escaped_name = g_uri_escape_string (BRASERO_FILE_NODE_NAME (node),
449
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
446
451
uri_len += strlen (escaped_name) + 1;
447
452
list = g_slist_prepend (list, escaped_name);
841
846
brasero_utils_unregister_string (key);
844
/* NOTE: no need to free graft->uri since that's key */
849
/* NOTE: no need to free graft->uri since that's the key */
845
850
g_slist_free (graft->nodes);
856
brasero_data_project_graft_is_needed (BraseroDataProject *self,
857
BraseroURINode *uri_node)
862
/* there aren't any node grafted for this URI. See if we should keep the
863
* URI in the hash; if so, the URI must have parents in the hash */
864
if (brasero_data_project_uri_has_parent (self, uri_node->uri)) {
865
/* here that means that this URI is nowhere in the tree but has
866
* parent URIs which are grafted. So keep it in the hash to
867
* signal that URI is not in the tree. */
871
brasero_data_project_uri_remove_graft (self, uri_node->uri);
850
875
static BraseroURINode *
851
876
brasero_data_project_uri_add_graft (BraseroDataProject *self,
852
877
const gchar *uri)
897
922
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
899
/* see if that's really needed */
900
if (g_hash_table_lookup (priv->grafts, uri))
903
924
/* Find all the nodes that should be grafted.
904
925
* NOTE: this must be done before asking for a new graft */
905
926
nodes = brasero_data_project_uri_to_nodes (self, uri);
1051
1075
graft = BRASERO_FILE_NODE_GRAFT (node);
1052
1076
uri_node = graft->node;
1054
if (g_slist_length (uri_node->nodes) == 1) {
1078
/* NOTE: after this function the graft is invalid */
1079
brasero_file_node_ungraft (node);
1081
if (!uri_node->nodes) {
1055
1082
/* that's the last node grafted for this URI.
1056
1083
* There are no more nodes for this URI after.
1057
1084
* See if we should keep the URI in the hash;
1058
1085
* if so, the URI must have parents in the hash
1060
if (brasero_data_project_uri_has_parent (self, uri_node->uri)) {
1061
/* here that means that this URI is
1062
* nowhere in the tree but has parent
1063
* URIs which are grafted. */
1064
g_slist_free (uri_node->nodes);
1065
uri_node->nodes = NULL;
1087
if (!brasero_data_project_uri_has_parent (self, uri_node->uri))
1068
1088
brasero_data_project_uri_remove_graft (self, uri_node->uri);
1071
uri_node->nodes = g_slist_remove (uri_node->nodes, node);
1073
1091
else if (!node->is_imported) {
1076
1094
/* This URI will need a graft if it hasn't one yet */
1077
1095
uri = brasero_data_project_node_to_uri (self, node);
1078
brasero_data_project_uri_graft_nodes (self, uri);
1097
if (!g_hash_table_lookup (priv->grafts, uri))
1098
brasero_data_project_uri_graft_nodes (self, uri);
1080
1100
/* NOTE: since the URI wasn't grafted it has to have a
1081
1101
* valid parent that's why we don't check the graft
1147
brasero_data_project_convert_to_fake (BraseroDataProject *self,
1148
BraseroFileNode *node)
1150
BraseroURINode *graft;
1151
BraseroDataProjectPrivate *priv;
1153
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
1155
/* make it a fake directory not to break order */
1156
node->is_fake = TRUE;
1157
node->is_loading = FALSE;
1158
node->is_tmp_parent = FALSE;
1160
brasero_file_node_ungraft (node);
1161
graft = brasero_data_project_uri_ensure_graft (self, NEW_FOLDER);
1162
brasero_file_node_graft (node, graft);
1163
brasero_data_project_node_changed (self, node);
1165
/* Remove 2 since we're not going to load its contents */
1167
g_signal_emit (self,
1168
brasero_data_project_signals [PROJECT_LOADED_SIGNAL],
1127
1174
brasero_data_project_remove_node (BraseroDataProject *self,
1128
1175
BraseroFileNode *node)
1134
1181
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
1136
1183
if (node->is_tmp_parent) {
1137
BraseroURINode *graft;
1139
1184
/* This node was created as a temporary parent, it doesn't exist
1140
1185
* so we replace it with a fake one. */
1142
1187
/* Don't exclude any URI since it doesn't exist apparently */
1144
/* No need to check for deep directory since that was in
1145
* the project as such. Keep it that way. */
1147
/* Remove 2 since we're not going to load its contents */
1149
g_signal_emit (self,
1150
brasero_data_project_signals [PROJECT_LOADED_SIGNAL],
1154
node->is_tmp_parent = FALSE;
1156
/* make it a fake directory not to break order */
1157
node->is_fake = TRUE;
1158
node->is_loading = FALSE;
1160
brasero_file_node_ungraft (node);
1161
graft = brasero_data_project_uri_ensure_graft (self, NEW_FOLDER);
1162
brasero_file_node_graft (node, graft);
1163
brasero_data_project_node_changed (self, node);
1189
/* No need to check for deep directory since that was in the
1190
* project as such. Keep it that way. */
1192
brasero_data_project_convert_to_fake (self, node);
1166
1195
else if (priv->loading && node->is_grafted) {
1167
/* that means that's a grafted that failed to load decrement by 2 */
1169
g_signal_emit (self,
1170
brasero_data_project_signals [PROJECT_LOADED_SIGNAL],
1196
/* that means that's a grafted that failed to load */
1197
brasero_data_project_convert_to_fake (self, node);
1175
1201
/* check for a sibling now (before destruction) */
1176
1202
imported_sibling = brasero_file_node_check_imported_sibling (node);
1178
1203
brasero_data_project_remove_real (self, node);
1180
1205
/* add the sibling now (after destruction) */
1222
1247
* used to remove imported nodes. */
1251
brasero_data_project_is_deep (BraseroDataProject *self,
1252
BraseroFileNode *parent,
1257
BraseroFileTreeStats *stats;
1258
BraseroDataProjectPrivate *priv;
1260
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
1262
/* if there are already deep files accepts new ones (includes the
1263
* possible imported ones. */
1264
stats = brasero_file_node_get_tree_stats (priv->root, NULL);
1265
if (stats->num_deep)
1268
/* This node could have been moved beyond the depth 6 only in one case,
1269
* which is with imported directories. Otherwise since we check
1270
* directories for a depth of 5, its parent would have already been
1272
parent_depth = brasero_file_node_get_depth (parent);
1274
if (parent_depth < 5)
1278
if (parent_depth < 6)
1282
if (brasero_data_project_file_signal (self, DEEP_DIRECTORY_SIGNAL, name))
1226
1289
brasero_data_project_move_node (BraseroDataProject *self,
1227
1290
BraseroFileNode *node,
1254
1317
/* see if we won't break the max path depth barrier */
1255
if (!node->is_file && brasero_file_node_get_depth (parent) == 5
1256
&& brasero_data_project_file_signal (self, DEEP_DIRECTORY_SIGNAL, BRASERO_FILE_NODE_NAME (node)))
1318
if (!brasero_data_project_is_deep (self, parent, BRASERO_FILE_NODE_NAME (node), node->is_file))
1259
1321
/* One case could make us fail: if there is the same name in
1283
1345
* move it should probably be a graft now.
1284
1346
* NOTE: we need to do it now before it gets unparented. */
1285
1347
uri = brasero_data_project_node_to_uri (self, node);
1286
brasero_data_project_uri_graft_nodes (self, uri);
1348
if (!g_hash_table_lookup (priv->grafts, uri))
1349
brasero_data_project_uri_graft_nodes (self, uri);
1289
1352
check_graft = FALSE;
1298
1361
/* unparent node now in case its target sibling is a parent */
1299
1362
former_parent = node->parent;
1300
1363
former_position = brasero_file_node_get_pos_as_child (node);
1364
stats = brasero_file_node_get_tree_stats (priv->root, NULL);
1301
1365
brasero_file_node_move_from (node, stats);
1303
1367
klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
1387
1451
* we need to add one with all nodes having the same
1389
1453
uri = brasero_data_project_node_to_uri (self, node);
1390
brasero_data_project_uri_graft_nodes (self, uri);
1454
if (!g_hash_table_lookup (priv->grafts, uri))
1455
brasero_data_project_uri_graft_nodes (self, uri);
1393
1458
/* now we can change the name */
1446
1511
/* If there is already a graft for this URI, then add node */
1447
1512
brasero_file_node_graft (node, graft);
1449
else if (node->is_symlink) {
1450
/* NOTE: info has the uri for the target of the symlink */
1451
graft = brasero_data_project_uri_ensure_graft (self, uri);
1452
brasero_file_node_graft (node, graft);
1454
1514
else if (node->parent == priv->root) {
1455
/* The node is at the root of the project; graft it */
1456
graft = brasero_data_project_uri_ensure_graft (self, uri);
1515
/* The node is at the root of the project; graft it as well as
1516
* all the nodes already in the tree with the same URI */
1517
graft = brasero_data_project_uri_graft_nodes (self, uri);
1457
1518
brasero_file_node_graft (node, graft);
1459
1520
else if (node->is_fake) {
1460
/* The node is a fake directory; graft it */
1461
graft = brasero_data_project_uri_ensure_graft (self, uri);
1462
brasero_file_node_graft (node, graft);
1521
/* The node is a fake directory; graft it as well as all the
1522
* nodes already in the tree with the same URI */
1523
graft = brasero_data_project_uri_graft_nodes (self, uri);
1465
1526
gchar *parent_uri;
1467
1529
parent_uri = brasero_data_project_node_to_uri (self, node->parent);
1530
name_uri = g_path_get_basename (uri);
1532
/* NOTE: in here use a special function here since that node
1533
* could already be in the tree but under its rightful parent
1534
* and then it won't have any graft yet. That's why these nodes
1535
* need to be grafted as well. */
1468
1536
if (parent_uri) {
1469
1537
guint parent_len;
1471
1539
parent_len = strlen (parent_uri);
1472
1540
if (strncmp (parent_uri, uri, parent_len)
1473
&& uri [parent_len] != G_DIR_SEPARATOR) {
1541
|| uri [parent_len] != G_DIR_SEPARATOR
1543
|| !BRASERO_FILE_NODE_NAME (node)
1544
|| strcmp (name_uri, BRASERO_FILE_NODE_NAME (node))) {
1474
1545
/* The node hasn't been put under its rightful
1475
1546
* parent from the original file system. That
1476
* means we must add a graft*/
1477
graft = brasero_data_project_uri_add_graft (self, uri);
1547
* means we must add a graft */
1548
graft = brasero_data_project_uri_graft_nodes (self, uri);
1478
1549
brasero_file_node_graft (node, graft);
1480
1551
/* NOTE: we don't need to check if the nodes's name
1490
1561
/* its father is probably an fake empty directory */
1491
graft = brasero_data_project_uri_add_graft (self, uri);
1562
graft = brasero_data_project_uri_graft_nodes (self, uri);
1492
1563
brasero_file_node_graft (node, graft);
1496
1568
/* check joliet compatibility; do it after node was created. */
1497
1569
if (strlen (BRASERO_FILE_NODE_NAME (node)) > 64)
1498
1570
brasero_data_project_joliet_add_node (self, node);
1572
if (priv->is_loading_contents)
1500
1575
/* Signal that something has changed in the tree */
1501
1576
klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
1502
1577
if (klass->node_added)
1574
1649
BraseroDataProjectPrivate *priv;
1576
1651
g_return_val_if_fail (BRASERO_IS_DATA_PROJECT (self), NULL);
1577
g_return_val_if_fail (file != NULL, NULL);
1652
g_return_val_if_fail (info != NULL, NULL);
1579
1654
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
1582
1657
parent = priv->root;
1584
node = brasero_file_node_check_name_existence (parent, BRASERO_VOLUME_FILE_NAME (file));
1659
node = brasero_file_node_check_name_existence (parent, g_file_info_get_name (info));
1661
/* The node exists but it may be that we've loaded the project
1662
* before. Then the necessary directories to hold the grafted
1663
* files will have been created as fake directories. We need to
1664
* replace those whenever we run into one but not lose their
1666
if (node->is_fake && node->is_tmp_parent) {
1667
BraseroGraft *graft;
1668
BraseroURINode *uri_node;
1670
graft = BRASERO_FILE_NODE_GRAFT (node);
1671
uri_node = graft->node;
1673
/* NOTE after this function graft is invalid */
1674
brasero_file_node_ungraft (node);
1676
/* see if uri_node is still needed */
1677
if (!uri_node->nodes
1678
&& !brasero_data_project_uri_has_parent (self, uri_node->uri))
1679
brasero_data_project_uri_remove_graft (self, uri_node->uri);
1682
node->is_fake = FALSE;
1684
node->union3.imported_address = g_file_info_get_attribute_int64 (info, BRASERO_IO_DIR_CONTENTS_ADDR);
1686
node->is_imported = TRUE;
1687
node->is_tmp_parent = FALSE;
1689
/* Something has changed, tell the tree */
1690
klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
1691
if (klass->node_changed)
1692
klass->node_changed (self, node);
1586
1697
if (brasero_data_project_file_signal (self, NAME_COLLISION_SIGNAL, BRASERO_FILE_NODE_NAME (node)))
1592
1703
brasero_data_project_remove_real (self, node);
1595
node = brasero_file_node_new_imported_session_file (file, parent, priv->sort_func);
1706
node = brasero_file_node_new_imported_session_file (info, parent, priv->sort_func);
1597
1708
/* In this case, there can be no graft, and furthermore the
1598
1709
* lengths of the names are not our problem. Just signal that
1622
1733
parent = priv->root;
1624
1735
/* check directory_depth */
1625
if (brasero_file_node_get_depth (parent) == 5) {
1626
if (brasero_data_project_file_signal (self, DEEP_DIRECTORY_SIGNAL, name))
1736
if (!brasero_data_project_is_deep (self, parent, name, FALSE))
1630
1739
node = brasero_file_node_check_name_existence (parent, name);
1760
brasero_data_project_update_uri (BraseroDataProject *self,
1761
BraseroFileNode *node,
1765
BraseroGraft *graft;
1766
BraseroURINode *uri_node;
1767
BraseroURINode *former_uri_node;
1769
graft = BRASERO_FILE_NODE_GRAFT (node);
1770
former_uri_node = graft->node;
1772
if (!strcmp (former_uri_node->uri, uri)) {
1773
/* Nothing needs update */
1777
/* different URIS; make sure the node still needs a graft:
1778
* - if so, update it
1779
* - if not, remove it */
1780
parent_uri = brasero_data_project_node_to_uri (self, node->parent);
1784
parent_len = strlen (parent_uri);
1786
if (strncmp (parent_uri, uri, parent_len)
1787
&& uri [parent_len] != G_DIR_SEPARATOR) {
1788
/* The node hasn't been put under its rightful parent
1789
* from the original file system. That means we must add
1790
* a graft or update the current one. */
1791
uri_node = brasero_data_project_uri_add_graft (self, uri);
1792
brasero_file_node_graft (node, uri_node);
1795
/* rightful parent: ungraft it */
1796
brasero_file_node_ungraft (node);
1799
g_free (parent_uri);
1802
uri_node = brasero_data_project_uri_add_graft (self, uri);
1803
brasero_file_node_graft (node, uri_node);
1806
/* the node was ungrafted, check if the former graft is still needed */
1807
brasero_data_project_graft_is_needed (self, former_uri_node);
1651
1811
brasero_data_project_node_loaded (BraseroDataProject *self,
1652
1812
BraseroFileNode *node,
1660
1820
BraseroDataProjectPrivate *priv;
1662
1822
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
1663
1824
type = g_file_info_get_file_type (info);
1664
1825
if (node->is_tmp_parent) {
1665
1826
/* we must make sure that this is really a directory */
1666
1827
if (type != G_FILE_TYPE_DIRECTORY) {
1667
BraseroURINode *graft;
1669
/* it isn't a directory so it won't be loaded but turned
1670
* into a fake one. Decrement the number of loading */
1672
g_signal_emit (self,
1673
brasero_data_project_signals [PROJECT_LOADED_SIGNAL],
1677
/* no need to check for deep directory since that was in
1678
* the project as such. Keep it that way. */
1680
/* make it a fake directory not to break order */
1681
node->is_fake = TRUE;
1682
node->is_loading = FALSE;
1683
node->is_tmp_parent = FALSE;
1685
1828
/* exclude the URI we're replacing */
1686
1829
brasero_data_project_exclude_uri (self, uri);
1687
brasero_file_node_ungraft (node);
1689
graft = brasero_data_project_uri_ensure_graft (self, NEW_FOLDER);
1690
brasero_file_node_graft (node, graft);
1691
brasero_data_project_node_changed (self, node);
1693
/* since that URI wasn't a folder no contents loading */
1830
brasero_data_project_convert_to_fake (self, node);
1715
1852
priv->loading);
1855
/* If the node is not grafted because it was put under its original
1856
* parent on the file system it comes from, then its parent URI can't
1857
* have changed (the parent it was put under had already its URI cleaned
1858
* of any symlink). Its URI may be different though if it's a symlink
1859
* but that case is treated somewhere else. */
1860
if (node->is_grafted) {
1861
/* The URI of the node could be different from the one we gave
1862
* earlier as brasero-io looks for parent symlinks and replace
1863
* them with their target. So since it's a graft, we need to
1864
* update the graft URI just to make sure. */
1865
brasero_data_project_update_uri (self, node, uri);
1718
1868
size = g_file_info_get_size (info);
1719
1869
if (type != G_FILE_TYPE_DIRECTORY) {
1720
if (BRASERO_SIZE_TO_SECTORS (size, 2048) > BRASERO_FILE_2G_LIMIT
1870
if (BRASERO_BYTES_TO_SECTORS (size, 2048) > BRASERO_FILE_2G_LIMIT
1721
1871
&& BRASERO_FILE_NODE_SECTORS (node) < BRASERO_FILE_2G_LIMIT) {
1722
1872
if (brasero_data_project_file_signal (self, G2_FILE_SIGNAL, g_file_info_get_name (info))) {
1723
1873
brasero_data_project_remove_node (self, node);
1728
1879
/* avoid signalling twice for the same directory */
1729
else if (!node->is_file
1730
&& brasero_file_node_get_depth (node) == 6
1731
&& brasero_data_project_file_signal (self, DEEP_DIRECTORY_SIGNAL, g_file_info_get_name (info))) {
1880
if (!brasero_data_project_is_deep (self, node->parent, BRASERO_FILE_NODE_NAME (node), node->is_file)) {
1732
1881
brasero_data_project_remove_node (self, node);
1736
size_changed = (BRASERO_SIZE_TO_SECTORS (size, 2048) != BRASERO_FILE_NODE_SECTORS (node));
1885
size_changed = (BRASERO_BYTES_TO_SECTORS (size, 2048) != BRASERO_FILE_NODE_SECTORS (node));
1737
1886
stats = brasero_file_node_get_tree_stats (priv->root, NULL);
1738
1887
brasero_file_node_set_from_info (node, stats, info);
1740
1889
/* Check it that needs a graft: this node has not been moved so we don't
1741
1890
* need to check these cases yet it could turn out that it was a symlink
1742
1891
* then we need a graft. */
1743
if (node->is_symlink) {
1892
if (g_file_info_get_is_symlink (info) && g_file_info_get_file_type (info) != G_FILE_TYPE_SYMBOLIC_LINK) {
1744
1893
BraseroURINode *graft;
1750
1899
brasero_data_project_exclude_uri (self, uri);
1753
/* NOTE: info has the uri for the target of the symlink */
1754
graft = brasero_data_project_uri_ensure_graft (self, g_file_info_get_symlink_target (info));
1902
/* NOTE: info has the uri for the target of the symlink.
1903
* NOTE 2: all nodes with target URI become grafted. */
1904
graft = brasero_data_project_uri_graft_nodes (self, g_file_info_get_symlink_target (info));
1755
1905
brasero_file_node_graft (node, graft);
1807
1956
size = g_file_info_get_size (info);
1808
1957
name = g_file_info_get_name (info);
1809
if (BRASERO_SIZE_TO_SECTORS (size, 2048) > BRASERO_FILE_2G_LIMIT
1958
if (BRASERO_BYTES_TO_SECTORS (size, 2048) > BRASERO_FILE_2G_LIMIT
1810
1959
&& BRASERO_FILE_NODE_SECTORS (node) < BRASERO_FILE_2G_LIMIT) {
1811
1960
if (brasero_data_project_file_signal (self, G2_FILE_SIGNAL, name)) {
1812
1961
brasero_data_project_remove_node (self, node);
1860
2008
/* make sure that name doesn't exist */
1861
2009
node = brasero_file_node_check_name_existence (parent, name);
1863
if (brasero_data_project_file_signal (self, NAME_COLLISION_SIGNAL, BRASERO_FILE_NODE_NAME (node))) {
2011
if (brasero_data_project_file_signal (self,
2012
NAME_COLLISION_SIGNAL,
2013
BRASERO_FILE_NODE_NAME (node))) {
1977
2130
size = g_file_info_get_size (info);
1978
if (BRASERO_SIZE_TO_SECTORS (size, 2048) > BRASERO_FILE_2G_LIMIT)
2131
if (BRASERO_BYTES_TO_SECTORS (size, 2048) > BRASERO_FILE_2G_LIMIT)
1979
2132
if (brasero_data_project_file_signal (self, G2_FILE_SIGNAL, name))
1982
else if (!brasero_file_node_get_depth (parent) == 5) {
2135
/* This is a special case where we won't try all checks for deep nested
2136
* files. Since this function is only used by brasero-data-vfs.c to
2137
* add the results of its exploration, we only check directories and
2138
* just check for a directory to have a depth of 6 (means parent has a
2140
else if (brasero_file_node_get_depth (parent) == 5) {
1983
2141
if (brasero_data_project_file_signal (self, DEEP_DIRECTORY_SIGNAL, name))
1987
node = brasero_file_node_new_from_info (info, parent, priv->sort_func);
1988
if (node->is_symlink) {
2145
node = brasero_file_node_new_from_info (info,
2149
if (g_file_info_get_is_symlink (info)
2150
&& g_file_info_get_file_type (info) != G_FILE_TYPE_SYMBOLIC_LINK) {
1991
2151
/* first we exclude the symlink, then we graft its target */
1992
symlink_uri = brasero_data_project_node_to_uri (self, node);
1993
brasero_data_project_exclude_uri (self, symlink_uri);
1994
g_free (symlink_uri);
2152
brasero_data_project_exclude_uri (self, uri);
1996
2154
/* then we add the node */
1997
2155
brasero_data_project_add_node_real (self,
2047
2207
typedef struct _MakeTrackData MakeTrackData;
2050
brasero_data_project_set_joliet_compliant_name (BraseroDataProject *self,
2051
BraseroFileNode *node,
2054
BraseroDataProjectPrivate *priv;
2055
BraseroJolietKey key;
2064
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
2066
brasero_data_project_joliet_set_key (&key, node);
2067
list = g_hash_table_lookup (priv->joliet, &key);
2068
name = BRASERO_FILE_NODE_NAME (node);
2070
/* see if it is joliet non compliant */
2072
len = strlen (name);
2073
memcpy (buffer, name, len);
2077
if (g_slist_length (list) == 1) {
2078
/* Simply return joliet name truncated to 64 chars.
2079
* try to keep the extension. */
2080
dot = g_utf8_strrchr (name, -1, '.');
2081
if (dot && strlen (dot) < 5 && strlen (dot) > 1 )
2082
retval = sprintf (buffer,
2097
num = g_slist_index (list, node);
2100
while (num / (width * 10)) width ++;
2103
/* try to keep the extension */
2104
dot = g_utf8_strrchr (name, -1, '.');
2105
if (dot && strlen (dot) < 5 && strlen (dot) > 1 )
2106
retval = sprintf (buffer,
2108
width - strlen (dot),
2113
retval = sprintf (buffer,
2122
2210
brasero_data_project_node_to_path (BraseroDataProject *self,
2123
BraseroFileNode *node,
2124
gboolean joliet_compat)
2211
BraseroFileNode *node)
2153
2241
/* Make sure path length didn't go over MAXPATHLEN. */
2154
if (!joliet_compat) {
2157
name = BRASERO_FILE_NODE_NAME (node);
2159
name_len = strlen (name);
2160
if (len + name_len > MAXPATHLEN)
2163
memcpy (path + len, name, name_len);
2167
/* must have enough room for 64 characters */
2168
if (len + 64 > MAXPATHLEN)
2171
len += brasero_data_project_set_joliet_compliant_name (self,
2242
name = BRASERO_FILE_NODE_NAME (node);
2244
name_len = strlen (name);
2245
if (len + name_len > MAXPATHLEN)
2248
memcpy (path + len, name, name_len);
2176
2251
g_slist_free (list);
2289
2362
callback_data.grafts = NULL;
2290
2363
callback_data.excluded = NULL;
2291
2364
callback_data.append_slash = append_slash;
2292
callback_data.joliet_compat = joliet_compat;
2294
2366
g_hash_table_foreach (priv->grafts,
2295
2367
(GHFunc) _foreach_grafts_make_list_cb,
2296
2368
&callback_data);
2298
2370
if (joliet_compat) {
2299
/* we have to make sure that even the files that are not grafted
2300
* have joliet compatible names. */
2371
/* Make sure that all nodes with incompatible joliet names are
2372
* added as graft points. */
2301
2373
g_hash_table_foreach (priv->joliet,
2302
2374
(GHFunc) _foreach_joliet_incompatible_make_list_cb,
2303
2375
&callback_data);
2392
brasero_data_project_has_symlinks (BraseroDataProject *self)
2394
BraseroDataProjectPrivate *priv;
2395
BraseroFileTreeStats *stats;
2397
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
2399
stats = brasero_file_node_get_tree_stats (priv->root, NULL);
2320
2407
brasero_data_project_is_joliet_compliant (BraseroDataProject *self)
2322
2409
BraseroDataProjectPrivate *priv;
2410
BraseroFileTreeStats *stats;
2324
2412
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
2414
stats = brasero_file_node_get_tree_stats (priv->root, NULL);
2326
2418
if (!priv->joliet || !g_hash_table_size (priv->joliet))
2564
2652
node->is_loading = FALSE;
2565
2653
node->is_reloading = FALSE;
2567
/* decrement that since we're not going to load anything */
2570
/* Signal that something has changed in the tree */
2571
if (klass->node_added)
2572
klass->node_added (self, node, NULL);
2655
/* Don't signal the node addition yet we'll do it later
2656
* when all the nodes are created */
2575
2659
node->is_file = FALSE;
2577
2661
node->is_loading = TRUE;
2578
2662
node->is_reloading = FALSE;
2580
/* No need to increment priv->loading here since that
2581
* was done at the creation of the temporary folder */
2583
/* Signal that something has changed in the tree */
2584
if (klass->node_added)
2585
klass->node_added (self, node, uri);
2664
/* Don't signal the node addition yet we'll do it later
2665
* when all the nodes are created */
2588
2668
else if (node) {
2594
2674
/* don't use brasero_data_project_add_loading_node since that way:
2595
2675
* - we don't check for sibling
2596
2676
* - we set right from the start the right name */
2597
if (uri != NEW_FOLDER) {
2677
if (uri != NEW_FOLDER)
2598
2678
node = brasero_file_node_new_loading (path, parent, priv->sort_func);
2600
/* Set loading counter to 2: 1 operation for loading the graft
2601
* point and 1 for loading its contents if that's a folder. */
2605
2680
node = brasero_file_node_new_empty_folder (path, parent, priv->sort_func);
2710
2785
return folders;
2789
brasero_data_project_load_contents_notify_directory (BraseroDataProject *self,
2790
BraseroFileNode *parent,
2791
BraseroDataNodeAddedFunc func)
2793
BraseroFileNode *child;
2796
child = BRASERO_FILE_NODE_CHILDREN (parent);
2800
BraseroFileNode *next;
2802
/* The child could be removed during the process */
2806
* This is to get the number of operations remaining before the
2807
* whole project is loaded.
2808
* +1 for loading information about a file or a directory (that
2809
* means they must not be fake).
2810
* +1 for loading the directory contents.
2812
if (child->is_fake) {
2813
/* This is a fake directory, there is no operation */
2814
res = func (self, child, NULL);
2819
uri = brasero_data_project_node_to_uri (self, child);
2820
res = func (self, child, uri);
2826
/* for whatever reason the node could have been invalidated */
2827
if (res && !child->is_file) {
2829
num += brasero_data_project_load_contents_notify_directory (self,
2841
brasero_data_project_load_contents_notify (BraseroDataProject *self)
2844
BraseroDataProjectClass *klass;
2845
BraseroDataProjectPrivate *priv;
2847
klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
2848
if (!klass->node_added)
2851
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
2853
/* we'll notify for every single node in the tree starting from the top.
2854
* NOTE: at this point there are only grafted nodes (fake or not) in the
2856
num = brasero_data_project_load_contents_notify_directory (self,
2714
2863
brasero_data_project_load_contents (BraseroDataProject *self,
2715
2864
GSList *grafts,
2719
2868
GSList *folders = NULL;
2720
BraseroDataProjectClass *klass;
2721
2869
BraseroDataProjectPrivate *priv;
2871
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
2872
priv->is_loading_contents = 1;
2723
2874
for (iter = grafts; iter; iter = iter->next) {
2724
2875
BraseroGraftPt *graft;
2726
2879
graft = iter->data;
2882
file = g_file_new_for_uri (graft->uri);
2883
uri = g_file_get_uri (file);
2884
g_object_unref (file);
2727
2889
folders = brasero_data_project_add_path (self,
2733
2898
for (iter = excluded; iter; iter = iter->next) {
2902
file = g_file_new_for_uri (iter->data);
2903
uri = g_file_get_uri (file);
2904
g_object_unref (file);
2737
2906
folders = brasero_data_project_add_excluded_uri (self,
2742
2912
/* Now load the temporary folders that were created */
2743
klass = BRASERO_DATA_PROJECT_GET_CLASS (self);
2744
priv = BRASERO_DATA_PROJECT_PRIVATE (self);
2746
2913
for (iter = folders; iter; iter = iter->next) {
2747
2914
BraseroURINode *graft;
2748
2915
BraseroFileNode *tmp;
2753
2920
/* get the URI for this node. There should be one now that all
2754
2921
* graft nodes are in the tree. */
2755
2922
uri = brasero_data_project_node_to_uri (self, tmp);
2924
/* This node has been grafted under a node that was
2925
* imported or was itself an imported node. Since there
2926
* is no imported nodes any more, then it has to become
2928
* NOTE: it has to be a directory */
2929
tmp->is_fake = TRUE;
2930
tmp->is_loading = FALSE;
2931
tmp->is_reloading = FALSE;
2933
graft = brasero_data_project_uri_ensure_graft (self, NEW_FOLDER);
2934
brasero_file_node_graft (tmp, graft);
2936
/* Don't signal the node addition yet we'll do it later
2937
* when all the nodes are created */
2757
2942
/* graft it ? */
2758
2943
graft = brasero_data_project_uri_ensure_graft (self, uri);
2759
2944
brasero_file_node_graft (tmp, graft);
2761
/* Signal that something has changed in the tree */
2762
if (klass->node_added)
2763
klass->node_added (self, tmp, uri);
2947
/* Don't signal the node addition yet we'll do it later when
2948
* all the nodes are created */
2767
2950
g_slist_free (folders);
2952
priv->loading = brasero_data_project_load_contents_notify (self);
2954
priv->is_loading_contents = 0;
2769
2955
return priv->loading;
3027
3213
/* get the new URI */
3028
3214
parent_uri = brasero_data_project_node_to_uri (BRASERO_DATA_PROJECT (monitor), parent);
3029
escaped_name = g_uri_escape_string (name, NULL, TRUE);
3215
escaped_name = g_uri_escape_string (name,
3216
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
3030
3218
uri = g_strconcat (parent_uri, G_DIR_SEPARATOR_S, escaped_name, NULL);
3031
3219
g_free (escaped_name);
3032
3220
g_free (parent_uri);
3064
3252
uri_node = graft->node;
3066
3254
/* get the new uri */
3067
escaped_name = g_uri_escape_string (name, NULL, TRUE);
3255
escaped_name = g_uri_escape_string (name,
3256
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
3068
3258
uri = g_build_path (G_DIR_SEPARATOR_S, parent_uri, escaped_name, NULL);
3069
3259
g_free (escaped_name);
3140
3330
parent = g_path_get_dirname (uri);
3143
escaped_name = g_uri_escape_string (real_name, NULL, TRUE);
3333
escaped_name = g_uri_escape_string (real_name,
3334
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
3144
3336
uri = g_strconcat (parent, G_DIR_SEPARATOR_S, escaped_name, NULL);
3145
3337
g_free (escaped_name);
3146
3338
g_free (parent);
3285
3477
brasero_data_project_joliet_remove_node (BRASERO_DATA_PROJECT (monitor), node);
3287
3479
/* see if we won't break the max path depth barrier */
3288
if (!node->is_file && brasero_file_node_get_depth (parent) == 5
3289
&& brasero_data_project_file_signal (BRASERO_DATA_PROJECT (monitor), DEEP_DIRECTORY_SIGNAL, BRASERO_FILE_NODE_NAME (node))) {
3480
if (!brasero_data_project_is_deep (BRASERO_DATA_PROJECT (monitor), parent, BRASERO_FILE_NODE_NAME (node), node->is_file)) {
3290
3481
brasero_data_project_remove_node (BRASERO_DATA_PROJECT (monitor), node);