brasero r1912 - in trunk: . src src/plugins/cdrkit src/plugins/growisofs
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1912 - in trunk: . src src/plugins/cdrkit src/plugins/growisofs
- Date: Sat, 14 Feb 2009 14:39:03 +0000 (UTC)
Author: philippr
Date: Sat Feb 14 14:39:03 2009
New Revision: 1912
URL: http://svn.gnome.org/viewvc/brasero?rev=1912&view=rev
Log:
2009-02-14 Philippe Rouquier <ykw localhost localdomain>
Moved joliet name mangling from data projects to mkisofs base.
NOTE: libisofs has its own internal mangling routines so it won't use it
* src/brasero-data-project.c (brasero_data_project_node_to_path),
(_foreach_grafts_make_list_cb),
(_foreach_joliet_incompatible_make_list_cb),
(brasero_data_project_get_contents):
* src/burn-mkisofs-base.c (_build_graft_point),
(brasero_mkisofs_base_mangle_joliet_name), (_foreach_write_grafts),
(brasero_mkisofs_base_write_grafts),
(brasero_mkisofs_base_write_to_files):
* src/burn-mkisofs-base.h:
* src/burn-track.c (brasero_track_get_data_paths):
* src/burn-track.h:
* src/plugins/cdrkit/burn-genisoimage.c
(brasero_genisoimage_set_argv_image):
* src/plugins/cdrtools/burn-mkisofs.c
(brasero_mkisofs_set_argv_image):
* src/plugins/growisofs/burn-growisofs.c
(brasero_growisofs_set_mkisofs_argv):
Modified:
trunk/ChangeLog
trunk/src/brasero-data-project.c
trunk/src/burn-mkisofs-base.c
trunk/src/burn-mkisofs-base.h
trunk/src/burn-track.c
trunk/src/burn-track.h
trunk/src/plugins/cdrkit/burn-genisoimage.c
trunk/src/plugins/growisofs/burn-growisofs.c
Modified: trunk/src/brasero-data-project.c
==============================================================================
--- trunk/src/brasero-data-project.c (original)
+++ trunk/src/brasero-data-project.c Sat Feb 14 14:39:03 2009
@@ -2202,7 +2202,6 @@
* Export tree internals into a track
*/
struct _MakeTrackData {
- gboolean joliet_compat;
gboolean append_slash;
GSList *grafts;
@@ -2212,82 +2211,9 @@
};
typedef struct _MakeTrackData MakeTrackData;
-static guint
-brasero_data_project_set_joliet_compliant_name (BraseroDataProject *self,
- BraseroFileNode *node,
- gchar *buffer)
-{
- BraseroDataProjectPrivate *priv;
- BraseroJolietKey key;
- guint retval;
- GSList *list;
- gchar *name;
- gchar *dot;
- gint width;
- gint num;
- gint len;
-
- priv = BRASERO_DATA_PROJECT_PRIVATE (self);
-
- brasero_data_project_joliet_set_key (&key, node);
- list = g_hash_table_lookup (priv->joliet, &key);
- name = BRASERO_FILE_NODE_NAME (node);
-
- /* see if it is joliet non compliant */
- if (!list) {
- len = strlen (name);
- memcpy (buffer, name, len);
- return len;
- }
-
- if (g_slist_length (list) == 1) {
- /* Simply return joliet name truncated to 64 chars.
- * try to keep the extension. */
- dot = g_utf8_strrchr (name, -1, '.');
- if (dot && strlen (dot) < 5 && strlen (dot) > 1 )
- retval = sprintf (buffer,
- "%.*s%s",
- 64 - strlen (dot),
- name,
- dot);
- else {
- retval = 64;
- memcpy (buffer,
- name,
- 64);
- }
-
- return 64;
- }
-
- num = g_slist_index (list, node);
-
- width = 1;
- while (num / (width * 10)) width ++;
- width = 64 - width;
-
- /* try to keep the extension */
- dot = g_utf8_strrchr (name, -1, '.');
- if (dot && strlen (dot) < 5 && strlen (dot) > 1 )
- retval = sprintf (buffer,
- "%.*s%i%s",
- width - strlen (dot),
- name,
- num,
- dot);
- else
- retval = sprintf (buffer,
- "%.*s%i",
- width,
- name,
- num);
- return retval;
-}
-
static gchar *
brasero_data_project_node_to_path (BraseroDataProject *self,
- BraseroFileNode *node,
- gboolean joliet_compat)
+ BraseroFileNode *node)
{
guint len;
GSList *list;
@@ -2307,6 +2233,7 @@
len = 0;
for (iter = list; iter; iter = iter->next) {
gchar *name;
+ guint name_len;
node = iter->data;
@@ -2317,27 +2244,14 @@
return NULL;
/* Make sure path length didn't go over MAXPATHLEN. */
- if (!joliet_compat) {
- guint name_len;
-
- name = BRASERO_FILE_NODE_NAME (node);
+ name = BRASERO_FILE_NODE_NAME (node);
- name_len = strlen (name);
- if (len + name_len > MAXPATHLEN)
- return NULL;
+ name_len = strlen (name);
+ if (len + name_len > MAXPATHLEN)
+ return NULL;
- memcpy (path + len, name, name_len);
- len += name_len;
- }
- else {
- /* must have enough room for 64 characters */
- if (len + 64 > MAXPATHLEN)
- return NULL;
-
- len += brasero_data_project_set_joliet_compliant_name (self,
- node,
- path + len);
- }
+ memcpy (path + len, name, name_len);
+ len += name_len;
}
g_slist_free (list);
@@ -2376,9 +2290,7 @@
if (uri && uri != NEW_FOLDER)
graft->uri = g_strdup (uri);
- graft->path = brasero_data_project_node_to_path (data->project,
- node,
- data->joliet_compat);
+ graft->path = brasero_data_project_node_to_path (data->project, node);
if (!node->is_file && data->append_slash) {
gchar *tmp;
@@ -2414,7 +2326,7 @@
continue;
graft = g_new0 (BraseroGraftPt, 1);
- graft->path = brasero_data_project_node_to_path (data->project, node, TRUE);
+ graft->path = brasero_data_project_node_to_path (data->project, node);
if (!node->is_file && data->append_slash) {
gchar *tmp;
@@ -2455,22 +2367,19 @@
callback_data.grafts = NULL;
callback_data.excluded = NULL;
callback_data.append_slash = append_slash;
- callback_data.joliet_compat = joliet_compat;
g_hash_table_foreach (priv->grafts,
(GHFunc) _foreach_grafts_make_list_cb,
&callback_data);
if (joliet_compat) {
- /* we have to make sure that even the files that are not grafted
- * have joliet compatible names. */
+ /* Make sure that all nodes with incompatible joliet names are
+ * added as graft points. */
g_hash_table_foreach (priv->joliet,
(GHFunc) _foreach_joliet_incompatible_make_list_cb,
&callback_data);
}
- /* Finally add all the symlinks */
-
if (grafts)
*grafts = callback_data.grafts;
Modified: trunk/src/burn-mkisofs-base.c
==============================================================================
--- trunk/src/burn-mkisofs-base.c (original)
+++ trunk/src/burn-mkisofs-base.c Sat Feb 14 14:39:03 2009
@@ -35,6 +35,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <sys/param.h>
#include <glib.h>
#include <glib-object.h>
@@ -54,12 +55,16 @@
gint excluded_fd;
GHashTable *grafts;
+ GHashTable *joliet;
guint found_video_ts:1;
+ guint use_joliet:1;
};
typedef struct _BraseroMkisofsBase BraseroMkisofsBase;
struct _BraseroWriteGraftData {
+ GHashTable *joliet;
+
BraseroMkisofsBase *base;
GError **error;
};
@@ -239,7 +244,8 @@
}
static gchar *
-_build_graft_point (const gchar *uri, const gchar *discpath) {
+_build_graft_point (const gchar *uri, const gchar *discpath)
+{
gchar *escaped_discpath;
gchar *graft_point;
gchar *path;
@@ -306,19 +312,153 @@
return BRASERO_BURN_OK;
}
+/**
+ * Manages the Joliet incompatible names and mangles names if need be
+ */
+
+static GHashTable *
+brasero_mkisofs_base_mangle_joliet_name (GHashTable *joliet,
+ const gchar *path,
+ gchar *buffer)
+{
+ gboolean has_slash = FALSE;
+ gint dot_pos = -1;
+ gint dot_len = -1;
+ gchar *name;
+ gint width;
+ gint start;
+ gint num;
+ gint end;
+
+ /* NOTE: this wouldn't work on windows (not a big deal) */
+ end = strlen (path);
+ if (!end) {
+ buffer [0] = '\0';
+ return joliet;
+ }
+
+ memcpy (buffer, path, MIN (end, MAXPATHLEN));
+ buffer [MIN (end, MAXPATHLEN)] = '\0';
+
+ /* move back until we find a character different from G_DIR_SEPARATOR */
+ end --;
+ while (end >= 0 && G_IS_DIR_SEPARATOR (path [end])) {
+ end --;
+ has_slash = TRUE;
+ }
+
+ /* There are only slashes */
+ if (end == -1)
+ return joliet;
+
+ start = end - 1;
+ while (start >= 0 && !G_IS_DIR_SEPARATOR (path [start])) {
+ /* Find the extension while at it */
+ if (dot_pos <= 0 && path [start] == '.')
+ dot_pos = start;
+
+ start --;
+ }
+
+ if (end - start <= 64)
+ return joliet;
+
+ name = buffer + start + 1;
+ if (dot_pos > 0)
+ dot_len = end - dot_pos + 1;
+
+ if (dot_len > 1 && dot_len < 5)
+ memcpy (name + 64 - dot_len,
+ path + dot_pos,
+ dot_len);
+
+ name [64] = '\0';
+
+ if (!joliet) {
+ joliet = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ NULL);
+
+ g_hash_table_insert (joliet, g_strdup (buffer), GINT_TO_POINTER (1));
+ if (has_slash)
+ strcat (buffer, G_DIR_SEPARATOR_S);
+
+ return joliet;
+ }
+
+ /* see if this path was already used */
+ num = GPOINTER_TO_INT (g_hash_table_lookup (joliet, buffer));
+ if (!num) {
+ g_hash_table_insert (joliet, g_strdup (buffer), GINT_TO_POINTER (1));
+
+ if (has_slash)
+ strcat (buffer, G_DIR_SEPARATOR_S);
+
+ return joliet;
+ }
+
+ /* NOTE: g_hash_table_insert frees key_path */
+ num ++;
+ g_hash_table_insert (joliet, g_strdup (buffer), GINT_TO_POINTER (num));
+
+ width = 1;
+ while (num / (width * 10)) width ++;
+
+ /* try to keep the extension */
+ if (dot_len < 5 && dot_len > 1 )
+ sprintf (name + (64 - width - dot_len),
+ "%i%s",
+ num,
+ path + dot_pos);
+ else
+ sprintf (name + (64 - width),
+ "%i",
+ num);
+
+ if (has_slash)
+ strcat (buffer, G_DIR_SEPARATOR_S);
+
+ return joliet;
+}
+
static gboolean
_foreach_write_grafts (const gchar *uri,
GSList *grafts,
BraseroWriteGraftData *data)
{
+ gchar buffer [MAXPATHLEN];
BraseroBurnResult result;
BraseroGraftPt *graft;
for (; grafts; grafts = grafts->next) {
+ const gchar *path;
+
graft = grafts->data;
+
+ if (!graft->path) {
+ result = brasero_mkisofs_base_write_graft (data->base,
+ graft->uri,
+ NULL,
+ data->error);
+ if (result != BRASERO_BURN_OK)
+ return TRUE;
+
+ continue;
+ }
+
+ if (data->base->use_joliet) {
+ data->joliet = brasero_mkisofs_base_mangle_joliet_name (data->joliet,
+ graft->path,
+ buffer);
+ path = buffer;
+ }
+ else
+ path = graft->path;
+
result = brasero_mkisofs_base_write_graft (data->base,
graft->uri,
- graft->path,
+ path,
data->error);
if (result != BRASERO_BURN_OK)
return TRUE;
@@ -336,11 +476,15 @@
callback_data.error = error;
callback_data.base = base;
+ callback_data.joliet = NULL;
result = g_hash_table_find (base->grafts,
(GHRFunc) _foreach_write_grafts,
&callback_data);
+ if (callback_data.joliet)
+ g_hash_table_destroy (callback_data.joliet);
+
if (result)
return BRASERO_BURN_ERR;
@@ -478,6 +622,7 @@
BraseroBurnResult
brasero_mkisofs_base_write_to_files (GSList *grafts,
GSList *excluded,
+ gboolean use_joliet,
const gchar *emptydir,
const gchar *videodir,
const gchar *grafts_path,
@@ -518,6 +663,7 @@
return BRASERO_BURN_ERR;
}
+ base.use_joliet = use_joliet;
base.emptydir = emptydir;
base.videodir = videodir;
Modified: trunk/src/burn-mkisofs-base.h
==============================================================================
--- trunk/src/burn-mkisofs-base.h (original)
+++ trunk/src/burn-mkisofs-base.h Sat Feb 14 14:39:03 2009
@@ -38,6 +38,7 @@
BraseroBurnResult
brasero_mkisofs_base_write_to_files (GSList *grafts,
GSList *excluded,
+ gboolean use_joliet,
const gchar *emptydir,
const gchar *videodir,
const gchar *grafts_path,
Modified: trunk/src/burn-track.c
==============================================================================
--- trunk/src/burn-track.c (original)
+++ trunk/src/burn-track.c Sat Feb 14 14:39:03 2009
@@ -783,6 +783,7 @@
BraseroBurnResult
brasero_track_get_data_paths (BraseroTrack *track,
+ gboolean use_joliet,
const gchar *grafts_path,
const gchar *excluded_path,
const gchar *emptydir,
@@ -798,6 +799,7 @@
data = (BraseroTrackData *) track;
result = brasero_mkisofs_base_write_to_files (data->grafts,
data->excluded,
+ use_joliet,
emptydir,
videodir,
grafts_path,
Modified: trunk/src/burn-track.h
==============================================================================
--- trunk/src/burn-track.h (original)
+++ trunk/src/burn-track.h Sat Feb 14 14:39:03 2009
@@ -265,6 +265,7 @@
BraseroBurnResult
brasero_track_get_data_paths (BraseroTrack *track,
+ gboolean use_joliet,
const gchar *grafts_path,
const gchar *excluded_path,
const gchar *emptydir,
Modified: trunk/src/plugins/cdrkit/burn-genisoimage.c
==============================================================================
--- trunk/src/plugins/cdrkit/burn-genisoimage.c (original)
+++ trunk/src/plugins/cdrkit/burn-genisoimage.c Sat Feb 14 14:39:03 2009
@@ -302,6 +302,7 @@
}
result = brasero_track_get_data_paths (track,
+ (type.subtype.fs_type & BRASERO_IMAGE_FS_JOLIET) != 0,
grafts_path,
excluded_path,
emptydir,
Modified: trunk/src/plugins/growisofs/burn-growisofs.c
==============================================================================
--- trunk/src/plugins/growisofs/burn-growisofs.c (original)
+++ trunk/src/plugins/growisofs/burn-growisofs.c Sat Feb 14 14:39:03 2009
@@ -332,6 +332,7 @@
}
result = brasero_track_get_data_paths (track,
+ (input.subtype.fs_type & BRASERO_IMAGE_FS_JOLIET) != 0,
grafts_path,
excluded_path,
emptydir,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]