Commit 7797ae9f authored by John Sullivan's avatar John Sullivan

Split out a couple of file-related utilities into a new file.

parent a5ee2d81
2000-01-03 John Sullivan <sullivan@eazel.com>
Started new file for file-related utilities in Nautilus.
* libnautilus/nautilus-file-utilities.h : new file
* libnautilus/nautilus-file-utilities.c : new file
* libnautilus/Makefile.am : added these two new files to the build.
* src/nautilus_bookmarklist.c:
(nautilus_bookmarklist_get_file_path): Deployed
nautilus_make_path() and nautilus_user_directory()
2000-01-03 Darin Adler <darin@eazel.com>
* configure.in: Added "-Wall -Wno-unused" to list of warnings.
......@@ -11,6 +23,13 @@
the correct "%ld".
* libnautilus/.cvsignore: Added some generated files.
2000-01-03 John Sullivan <sullivan@eazel.com>
* src/nautilus_bookmarklist.c:
(nautilus_bookmarklist_save_file): Took out unused local
variables. My compiler didn't notice these because -Wall
isn't in our compile flags. Darin is fixing the compile flags.
2000-01-03 Elliot Lee <sopwith@redhat.com>
* All files: Update copyright notices.
......
......@@ -18,6 +18,7 @@ libnautilusinclude_HEADERS= \
gtkflist.h \
gtkscrollframe.h \
nautilus.h \
nautilus-file-utilities.h \
ntl-content-view-client.h \
ntl-meta-view-client.h \
ntl-view-client.h
......@@ -29,6 +30,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gnome-icon-container.c \
gtkflist.c \
gtkscrollframe.c \
nautilus-file-utilities.c \
ntl-content-view-client.c \
ntl-meta-view-client.c \
ntl-view-client.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-file-utilities..c - implementation of file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#include <gnome.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "nautilus-file-utilities.h"
const char* const nautilus_user_directory_name = ".gnomad";
const unsigned default_nautilus_directory_mode = 0755;
/**
* nautilus_make_path:
*
* Make a path name from a base path and name. The base path
* can end with or without a separator character.
*
* Return value: the combined path name.
**/
gchar *
nautilus_make_path(const gchar *path, const gchar* name)
{
gboolean insert_separator;
gint path_length;
gchar *result;
path_length = strlen(path);
insert_separator = path_length > 0 &&
strlen(name) > 0 &&
path[path_length - 1] != G_DIR_SEPARATOR;
if (insert_separator)
{
result = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
}
else
{
result = g_strconcat(path, name, NULL);
}
return result;
}
/**
* nautilus_user_directory:
*
* Get the path for the directory containing nautilus settings.
*
* Return value: the directory path.
**/
const gchar *
nautilus_user_directory()
{
static gchar *user_directory = NULL;
if (user_directory == NULL)
{
user_directory = nautilus_make_path(g_get_home_dir(),
nautilus_user_directory_name);
if (!g_file_exists(user_directory))
{
mkdir(user_directory, default_nautilus_directory_mode);
}
}
if (!g_file_test(user_directory, G_FILE_TEST_ISDIR))
{
/* Bad news, directory still isn't there.
* Report this to user somehow.
*/
g_assert_not_reached();
}
return user_directory;
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-file-utilities.h - interface for file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_FILE_UTILITIES_H
#define NAUTILUS_FILE_UTILITIES_H 1
gchar *nautilus_make_path (const gchar *path, const gchar* name);
const gchar *nautilus_user_directory (void);
#endif /* NAUTILUS_FILE_UTILITIES_H */
......@@ -18,6 +18,7 @@ libnautilusinclude_HEADERS= \
gtkflist.h \
gtkscrollframe.h \
nautilus.h \
nautilus-file-utilities.h \
ntl-content-view-client.h \
ntl-meta-view-client.h \
ntl-view-client.h
......@@ -29,6 +30,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gnome-icon-container.c \
gtkflist.c \
gtkscrollframe.c \
nautilus-file-utilities.c \
ntl-content-view-client.c \
ntl-meta-view-client.c \
ntl-view-client.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-file-utilities..c - implementation of file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#include <gnome.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "nautilus-file-utilities.h"
const char* const nautilus_user_directory_name = ".gnomad";
const unsigned default_nautilus_directory_mode = 0755;
/**
* nautilus_make_path:
*
* Make a path name from a base path and name. The base path
* can end with or without a separator character.
*
* Return value: the combined path name.
**/
gchar *
nautilus_make_path(const gchar *path, const gchar* name)
{
gboolean insert_separator;
gint path_length;
gchar *result;
path_length = strlen(path);
insert_separator = path_length > 0 &&
strlen(name) > 0 &&
path[path_length - 1] != G_DIR_SEPARATOR;
if (insert_separator)
{
result = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
}
else
{
result = g_strconcat(path, name, NULL);
}
return result;
}
/**
* nautilus_user_directory:
*
* Get the path for the directory containing nautilus settings.
*
* Return value: the directory path.
**/
const gchar *
nautilus_user_directory()
{
static gchar *user_directory = NULL;
if (user_directory == NULL)
{
user_directory = nautilus_make_path(g_get_home_dir(),
nautilus_user_directory_name);
if (!g_file_exists(user_directory))
{
mkdir(user_directory, default_nautilus_directory_mode);
}
}
if (!g_file_test(user_directory, G_FILE_TEST_ISDIR))
{
/* Bad news, directory still isn't there.
* Report this to user somehow.
*/
g_assert_not_reached();
}
return user_directory;
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-file-utilities.h - interface for file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_FILE_UTILITIES_H
#define NAUTILUS_FILE_UTILITIES_H 1
gchar *nautilus_make_path (const gchar *path, const gchar* name);
const gchar *nautilus_user_directory (void);
#endif /* NAUTILUS_FILE_UTILITIES_H */
......@@ -18,6 +18,7 @@ libnautilusinclude_HEADERS= \
gtkflist.h \
gtkscrollframe.h \
nautilus.h \
nautilus-file-utilities.h \
ntl-content-view-client.h \
ntl-meta-view-client.h \
ntl-view-client.h
......@@ -29,6 +30,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gnome-icon-container.c \
gtkflist.c \
gtkscrollframe.c \
nautilus-file-utilities.c \
ntl-content-view-client.c \
ntl-meta-view-client.c \
ntl-view-client.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-file-utilities..c - implementation of file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#include <gnome.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "nautilus-file-utilities.h"
const char* const nautilus_user_directory_name = ".gnomad";
const unsigned default_nautilus_directory_mode = 0755;
/**
* nautilus_make_path:
*
* Make a path name from a base path and name. The base path
* can end with or without a separator character.
*
* Return value: the combined path name.
**/
gchar *
nautilus_make_path(const gchar *path, const gchar* name)
{
gboolean insert_separator;
gint path_length;
gchar *result;
path_length = strlen(path);
insert_separator = path_length > 0 &&
strlen(name) > 0 &&
path[path_length - 1] != G_DIR_SEPARATOR;
if (insert_separator)
{
result = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
}
else
{
result = g_strconcat(path, name, NULL);
}
return result;
}
/**
* nautilus_user_directory:
*
* Get the path for the directory containing nautilus settings.
*
* Return value: the directory path.
**/
const gchar *
nautilus_user_directory()
{
static gchar *user_directory = NULL;
if (user_directory == NULL)
{
user_directory = nautilus_make_path(g_get_home_dir(),
nautilus_user_directory_name);
if (!g_file_exists(user_directory))
{
mkdir(user_directory, default_nautilus_directory_mode);
}
}
if (!g_file_test(user_directory, G_FILE_TEST_ISDIR))
{
/* Bad news, directory still isn't there.
* Report this to user somehow.
*/
g_assert_not_reached();
}
return user_directory;
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-file-utilities.h - interface for file manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_FILE_UTILITIES_H
#define NAUTILUS_FILE_UTILITIES_H 1
gchar *nautilus_make_path (const gchar *path, const gchar* name);
const gchar *nautilus_user_directory (void);
#endif /* NAUTILUS_FILE_UTILITIES_H */
......@@ -25,6 +25,8 @@
#include "nautilus.h"
#include "nautilus-bookmarklist.h"
#include <libnautilus/nautilus-file-utilities.h>
#include <gnome-xml/parser.h>
#include <gnome-xml/tree.h>
......@@ -248,18 +250,8 @@ nautilus_bookmarklist_get_file_path (NautilusBookmarklist *bookmarks)
static gchar *file_path = NULL;
if (file_path == NULL)
{
file_path = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, ".gnomad", NULL);
/* FIXME: make and use covers for these file-manipulation routines */
if (access(file_path, R_OK) != 0)
{
mkdir(file_path, default_gnomad_directory_mode);
}
file_path = g_strconcat(file_path,
G_DIR_SEPARATOR_S,
"bookmarks.xml",
NULL);
file_path = nautilus_make_path(nautilus_user_directory(),
"bookmarks.xml");
}
return file_path;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment