Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=grape.git;a=commitdiff;h=24ffe5a1e998cbd4620875df257ae5275fc52a86

commit 24ffe5a1e998cbd4620875df257ae5275fc52a86
Author: James Buren <r...@frugalware.org>
Date:   Sun Apr 4 05:48:54 2010 -0500

build_filename.c/exports.h
* add function for returning the absolute path to a filename

diff --git a/src/build_filename.c b/src/build_filename.c
new file mode 100644
index 0000000..7b0ef96
--- /dev/null
+++ b/src/build_filename.c
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 James Buren
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to 
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include "exports.h"
+
+gchar *build_filename(const gchar *filename) {
+  gchar *cur_dir;
+  gchar *path;
+
+  if(g_path_is_absolute(filename))
+    return g_strdup(filename);
+
+  cur_dir = g_get_current_dir();
+
+  path = g_build_filename(cur_dir,filename,NULL);
+
+  g_free(cur_dir);
+
+  return path;
+}
diff --git a/src/exports.h b/src/exports.h
index 21d3111..921cc39 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -42,6 +42,7 @@ GtkWidget *text_widget_new(SharedInfo *info);
GtkWidget *statusbar_new(SharedInfo *info);
SharedInfo *window_new(const gchar *filename);
gchar *get_filename(GtkWindow *window,gboolean open);
+gchar *build_filename(const gchar *filename);
void update_action(SharedInfo *info,const gchar *stock,const gchar *format,...);
void display_error(SharedInfo *info,const gchar *format,...);
void box_pack_widgets(GtkWidget *box,gboolean expand,...);
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to