OpenCores
URL https://opencores.org/ocsvn/copyblaze/copyblaze/trunk

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [sw/] [tools/] [asm/] [pBlazASM/] [pBlazDIS/] [pbLibgen.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ameziti
/*
2
 *  Copyright © 2003..2010 : Henk van Kampen <henk@mediatronix.com>
3
 *
4
 *      This file is part of pBlazDIS.
5
 *
6
 *  pBlazMRG is free software: you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation, either version 3 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  pBlazDIS is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with pBlazDIS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
 
20
#include <stdlib.h>
21
#include <string.h>
22
 
23
//!
24
// operating system dependent filename processing functions
25
//
26
char * basename( const char * path ) {
27
        char * ptr = strrchr( path, '\\' ) ;
28
        return ptr ? ptr + 1 : (char *) path ;
29
}
30
 
31
char * filename( const char * path ) {
32
        char * ptr = strrchr( path, '\\' ) ;
33
        char * b = strdup( ptr ? ptr + 1 : (char *) path ) ;
34
        char * p = strrchr( b, '.' ) ;
35
        if ( p != NULL )
36
                *p = '\0' ;
37
        return b ;
38
}
39
 
40
char * dirname( const char * path ) {
41
        char * newpath ;
42
        const char * slash ;
43
        int length ;
44
 
45
        slash = strrchr( path, '\\' ) ;
46
        if ( slash == 0 ) {
47
                path = "." ;
48
                length = 1 ;
49
        } else {
50
                while ( slash > path && *slash == '\\' )
51
                        slash -= 1 ;
52
                length = slash - path + 1 ;
53
        }
54
        newpath = (char *) malloc( length + 1 ) ;
55
        if ( newpath == 0 )
56
                return 0 ;
57
        strncpy( newpath, path, length ) ;
58
        newpath[ length ] = 0 ;
59
        return newpath ;
60
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.