make_relative_filename(3alleg4) Allegro manual make_relative_filename(3alleg4)NAME
make_relative_filename - Tries to make a relative filename from absolute path and filename. Allegro game programming library.
SYNOPSIS
#include <allegro.h>
char *make_relative_filename(char *dest, const char *path, const char *filename, int size);
DESCRIPTION
Attempts to make a relative filename from an absolute path and an absolute filename, storing at most `size' bytes into the `dest' buffer.
This function won't work if the paths are not canonical under the current platform (see canonicalize_filename()). Also, `dest' cannot be
used as input value for `path' or `filename'. Example:
char base[] = "/long/absolute/path/program.exe";
char user_input[] = "/nice/and/short.txt";
...
make_relative_filename(buf, base, user_input, sizeof(buf));
/* Under Unix buf would contain:
../../../nice/and/short.txt */
RETURN VALUE
Returns a copy of the `dest' parameter if it succeeds or NULL if it fails (eg. under DOS, one path starts with "C:" and another with
"A:").
SEE ALSO make_absolute_filename(3alleg4), is_relative_filename(3alleg4), canonicalize_filename(3alleg4)Allegro version 4.4.2 make_relative_filename(3alleg4)
Check Out this Related Man Page
canonicalize_filename(3alleg4) Allegro manual canonicalize_filename(3alleg4)NAME
canonicalize_filename - Converts any filename into its canonical form. Allegro game programming library.
SYNOPSIS
#include <allegro.h>
char *canonicalize_filename(char *dest, const char *filename, int size);
DESCRIPTION
Converts any filename into its canonical form, i.e. the minimal absolute filename describing the same file and fixing incorrect for-
ward/backward slashes for the current platform, storing at most `size' bytes into the `dest' buffer. You can use the same buffer both as
input and output because Allegro internally works on a copy of the input before touching `dest'. Example:
char buf[256];
...
canonicalize_filename(buf, "~/../s22/..\t3st///hi.c",
sizeof(buf));
/* Running this under Unix would
return: /home/t3st/hi.c */
Note that this function won't work as expected if the path to canonicalize comes from another platform (eg. a "c:something" path will
canonicalize into something really wrong under Unix: "/current/path/c:/something").
RETURN VALUE
Returns a copy of the `dest' parameter.
SEE ALSO fix_filename_case(3alleg4), fix_filename_slashes(3alleg4)Allegro version 4.4.2 canonicalize_filename(3alleg4)
Hello,
I am trying to work with filename in Unix.
So in my example a have a filename like : ABC_totoalerte.txt and I want just to capture totoalerte.txt.
How can i do it , i check it with cut -c,4-* but it didn't work.
Can you help me about this problem. Thanks.. (5 Replies)
Hi,
Any help on this would be very appreciated.
I capture the full path & filename in a variable like (varFile=/home/user/extfile.txt). Now in my shell script I have to use only the filename part i.e. extfile.txt. How do I extract only the filename part from the variable?
Thanks in... (3 Replies)
I need help with this:
Can any one tell me what does these below mean:
1. "\(.\).*") != '/'
2. sed 's+^\./++;s+/.*++'
3. sed "s+${f}/+ +
Thanks in advance (7 Replies)
In a foreach loop I end up with $file containing the filename INCLUDING the whole path. I want this reduced to just the filename, but I can't seem to remember how I did it some years back. I am sure I can do it with "sed", but I am pretty sure I have seen a simpler command.
Anyone?
borgeh (3 Replies)
Hello,
I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it:
char* getext(char *file)
{
char *extension;
int i, j;... (5 Replies)
If I have a filename as
filename.txt.20090807
and I use
for FILE in `find . -name "filename*" -type f`
do
my_time=${FILE#./filename.txt.}
I get my output as 20090807
However if my filename is
filename.Y20090807.txt
Is there a way I can use metacharacters in my... (3 Replies)
Hi,
How can I extract parts from an absolute path?
For example :
The absolute path is /dir1/dir2/dir3/dir4/dir5.I need the relative path starting with directory given as parameter : for instance if the parameter is dir3 then the result should be dir3/dir4/dir5
I need generic solution... (9 Replies)
Hi everybody.
I need a command to print the absolute path of files which name starts always with a pattern (MOD03), independently on where they are in the filesystem.
I have tryedls -ld ${INPUTPREFIX}/*/*/* | grep MOD03 | awk '{ print $8 }'but I have to use "/*/*/*" in this case to have the... (5 Replies)
Hello all,
From the following input :
/path/to/file.txt
/path/to/file2.txt
/another/path/to/another/f.txt
/x/y/z/FILE.txt
/x/y/z/FILE2.txt
can someone help me having the following output with a awk command ?
/path/to/ file.txt file2.txt /another/path/to/another/ f.txt /x/y/z/ FILE.txt... (4 Replies)
if filename.txt is in used, exit, else continue.
i tried to use fuser -c filename.txt, but returned bunch out PIDs eventhough filename.txt is not in used.
any idea ? (10 Replies)
$ x="/home/guru/temp/f1.txt"
$ echo $x | sed 's^.*/^^'
This will give the absolute path f1.txt. I don't understand WHY it works. How is it determining the last "/" character exactly? (7 Replies)
Well since Windows always laments over some of my files having a too long "path+filename" and it gets in the way of copying complete directory structures I would love to have a DOS Script that helps me with finding those.
I already tried DCSoft Long Filename Finder but that is neither DOS based... (3 Replies)
Hi,
I am writing in a file through cat command. This file will contain the path of file along with filename. e.g. /home/user/folder1/folder2/filename.txt
There might be very large number of this path in same file like say 140
when I try to run while command:
while read -r file
do
//command... (8 Replies)