mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
New path utility
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21534 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8fae8b9404
commit
37df5e2822
5 changed files with 205 additions and 2 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
* Source/NSPathUtilities.m: Fix to avoid duplicate paths.
|
||||
Fix bug in order of application paths.
|
||||
* Tools/gspath.m: new utility to display paths/directories
|
||||
* Tools/gspath.1: man page for gspath
|
||||
* Tools/GNUmakefile: build and install gspath
|
||||
|
||||
2005-07-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ cvtenc.m \
|
|||
defaults.m \
|
||||
gdnc.m \
|
||||
gdomap.c \
|
||||
gspath.m \
|
||||
pldes.m \
|
||||
plser.m \
|
||||
plmerge.m \
|
||||
|
|
|
@ -41,7 +41,8 @@ DTD_FILES = plist-0_9.dtd \
|
|||
gsdoc-1_0_1.rnc
|
||||
|
||||
# Manual pages to install
|
||||
MAN1_PAGES = gdnc.1 autogsdoc.1 cvtenc.1 defaults.1 pldes.1 sfparse.1 xmlparse.1
|
||||
MAN1_PAGES = gdnc.1 autogsdoc.1 cvtenc.1 defaults.1 gspath.1 \
|
||||
pldes.1 sfparse.1 xmlparse.1
|
||||
MAN7_PAGES = gsdoc.7
|
||||
MAN8_PAGES = gdomap.8
|
||||
|
||||
|
@ -49,7 +50,7 @@ MAN8_PAGES = gdomap.8
|
|||
ifeq ($(add),yes)
|
||||
TOOL_NAME = autogsdoc cvtenc plmerge sfparse xmlparse
|
||||
else
|
||||
TOOL_NAME = autogsdoc cvtenc gdnc defaults pl plmerge \
|
||||
TOOL_NAME = autogsdoc cvtenc gdnc gspath defaults pl plmerge \
|
||||
plparse sfparse pldes plser pl2link xmlparse
|
||||
CTOOL_NAME = gdomap
|
||||
|
||||
|
@ -63,6 +64,7 @@ autogsdoc_OBJC_FILES = autogsdoc.m AGSParser.m AGSOutput.m AGSIndex.m AGSHtml.m
|
|||
cvtenc_OBJC_FILES = cvtenc.m
|
||||
gdomap_C_FILES = gdomap.c
|
||||
gdnc_OBJC_FILES = gdnc.m
|
||||
gspath_OBJC_FILES = gspath.m
|
||||
defaults_OBJC_FILES = defaults.m
|
||||
dread_OBJC_FILES = dread.m
|
||||
dremove_OBJC_FILES = dremove.m
|
||||
|
|
56
Tools/gspath.1
Normal file
56
Tools/gspath.1
Normal file
|
@ -0,0 +1,56 @@
|
|||
.\"gspath(1) man page
|
||||
.\"put together by Richard Frith-Macdoanld <rfm.gnu.org>
|
||||
.\"Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
.\"Copying and distribution of this file, with or without modification,
|
||||
.\"are permitted in any medium without royalty provided the copyright
|
||||
.\"notice and this notice are preserved.
|
||||
.\"
|
||||
.\"Process this file with
|
||||
.\"groff -man -Tascii gspath.1
|
||||
.\"
|
||||
.TH GSPATH 1 "July 2005" GNUstep "GNUstep System Manual"
|
||||
.SH NAME
|
||||
gspath \- Utility to display standard directory/path information
|
||||
.SH SYNOPSIS
|
||||
.B gspath
|
||||
.P
|
||||
.SH DESCRIPTION
|
||||
This utility can be used to print out a single directory or path in order
|
||||
for external applications to know what paths the GNUstep system is using.
|
||||
It was written to provide information for the GNUstep make package.
|
||||
.P
|
||||
The
|
||||
.B gspath
|
||||
usility is called with exactly one argument, which determines what it prints.
|
||||
.P
|
||||
.SH Arguments
|
||||
To display the path to the defaults directory for the current user, use the
|
||||
.B defaults
|
||||
argument.
|
||||
.P
|
||||
To display the directory search path needed to locate dynamic libraries,
|
||||
use the
|
||||
.B libpath
|
||||
argument.
|
||||
.P
|
||||
To display the directory search path needed to locate commmand-line programs,
|
||||
use the
|
||||
.B path
|
||||
argument.
|
||||
.P
|
||||
To display the GNUstep home directory of the current user, use the
|
||||
.B user
|
||||
argument.
|
||||
.P
|
||||
.SH HISTORY
|
||||
Work on
|
||||
.B gspath
|
||||
started July 2005.
|
||||
.PP
|
||||
This manual page first appeared in gnustep-base 1.11.1 (July 2005).
|
||||
.P
|
||||
.SH AUTHORS
|
||||
.B gspath
|
||||
was written by Richard Frith-McDonald <rfm@gnu.org>.
|
||||
.PP
|
||||
This man page was written by Richard Frith-McDonald <rfm@gnu.org>.
|
141
Tools/gspath.m
Normal file
141
Tools/gspath.m
Normal file
|
@ -0,0 +1,141 @@
|
|||
/** This utility provides path/directory layout information for GNUstep.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Created: July 2005
|
||||
|
||||
This file is part of the GNUstep Project
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
|
||||
/**
|
||||
<p>The 'gspath' utility prints out various items of path/directory
|
||||
information (one item at a time).<br />
|
||||
The program always takes a single argument ... selecting the information
|
||||
to be printed.</p>
|
||||
The arguments and their meanings are -<br />
|
||||
<deflist>
|
||||
<term>defaults</term>
|
||||
<desc>The GNUstep defaults directory of the current user</desc>
|
||||
<term>libpath</term>
|
||||
<desc>A path specification which may be used to add all the standard
|
||||
GNUstep directories where dynamic libraries are normally stored.<br />
|
||||
you might do 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`gspath libpath`' to make
|
||||
use of this.</desc>
|
||||
<term>path</term>
|
||||
<desc>A path specification which may be used to add all the standard
|
||||
GNUstep directories where command-line programs are normally stored.<br />
|
||||
you might do 'PATH=$PATH:`gspath path`' to make use of this.</desc>
|
||||
<term>user</term>
|
||||
<desc>The GNUstep home directory of the current user</desc>
|
||||
</deflist>
|
||||
*/
|
||||
int
|
||||
main(int argc, char** argv, char **env)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSProcessInfo *proc;
|
||||
NSArray *args;
|
||||
|
||||
#ifdef GS_PASS_ARGUMENTS
|
||||
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
|
||||
#endif
|
||||
pool = [NSAutoreleasePool new];
|
||||
proc = [NSProcessInfo processInfo];
|
||||
if (proc == nil)
|
||||
{
|
||||
GSPrintf(stderr, @"gspath: unable to get process information!\n");
|
||||
[pool release];
|
||||
return 1;
|
||||
}
|
||||
|
||||
args = [proc arguments];
|
||||
|
||||
if ([args count] == 2)
|
||||
{
|
||||
BOOL ok = YES;
|
||||
NSString *name = [[args objectAtIndex: 1] lowercaseString];
|
||||
NSString *sep;
|
||||
|
||||
#ifdef __MINGW__
|
||||
sep = @";";
|
||||
#else
|
||||
sep = @":";
|
||||
#endif
|
||||
|
||||
if ([name isEqualToString: @"defaults"] == YES)
|
||||
{
|
||||
GSPrintf(stdout, @"%@", GSDefaultsRootForUser(nil));
|
||||
}
|
||||
else if ([name isEqualToString: @"path"] == YES)
|
||||
{
|
||||
NSArray *directories;
|
||||
NSString *path;
|
||||
|
||||
directories = NSSearchPathForDirectoriesInDomains
|
||||
(GSToolsDirectory, NSAllDomainsMask, YES);
|
||||
path = [directories componentsJoinedByString: sep];
|
||||
GSPrintf(stdout, @"%@", path);
|
||||
}
|
||||
else if ([name isEqualToString: @"libpath"] == YES)
|
||||
{
|
||||
NSArray *directories;
|
||||
NSString *path;
|
||||
|
||||
directories = NSSearchPathForDirectoriesInDomains
|
||||
(GSLibrariesDirectory, NSAllDomainsMask, YES);
|
||||
path = [directories componentsJoinedByString: sep];
|
||||
GSPrintf(stdout, @"%@", path);
|
||||
}
|
||||
else if ([name isEqualToString: @"user"] == YES)
|
||||
{
|
||||
GSPrintf(stdout, @"%@", NSHomeDirectory());
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = NO; // Unrecognised option
|
||||
}
|
||||
if (ok == YES)
|
||||
{
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
GSPrintf(stderr,
|
||||
@"The 'gspath' utility prints out various items of path/directory\n"
|
||||
@"information (one item at a time).\n"
|
||||
@"The program always takes a single argument ... selecting the information\n"
|
||||
@"to be printed.\n\n"
|
||||
@"The arguments and their meanings are -\n\n"
|
||||
@"defaults\n"
|
||||
@" The GNUstep defaults directory of the current user\n\n"
|
||||
@"libpath\n"
|
||||
@" A path specification which may be used to add all the standard GNUstep\n"
|
||||
@" directories where dynamic libraries are normally stored.\n\n"
|
||||
@" you might do 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`gspath libpath`' to make\n"
|
||||
@" use of this.\n\n"
|
||||
@"path\n"
|
||||
@" A path specification which may be used to add all the standard GNUstep\n"
|
||||
@" directories where command-line programs are normally stored.\n"
|
||||
@" you might do 'PATH=$PATH:`gspath path`' to make use of this.\n\n"
|
||||
@"user\n"
|
||||
@" The GNUstep home directory of the current user\n\n"
|
||||
);
|
||||
[pool release];
|
||||
return 1;
|
||||
}
|
Loading…
Reference in a new issue