OSDN Git Service

(LibGoblin)
[drdeamon64/drdeamon64.git] / libgoblin / drd64_libgoblin_srcfile.c
index d04661c..f2c5187 100644 (file)
@@ -144,7 +144,7 @@ LibGoblin_SrcFile   *
        SrcFile_SearchSrcFile(
                        LibGoblin_BinaryFile    *p_bfile,
                        char    *pstr_filename,
-                       char    *pstr_pathname )
+                       char    *pstr_path )
 {
        int             i_cnt;
        int             i_result;
@@ -153,7 +153,6 @@ LibGoblin_SrcFile   *
 
        assert( NULL != p_bfile );
        assert( NULL != pstr_filename );
-       assert( NULL != pstr_pathname );
 
        dw_hash = Common_CalcDJBhash( pstr_filename );
 
@@ -167,12 +166,15 @@ LibGoblin_SrcFile *
                i_result        = strncmp( pstr_filename, p_srcfile->str_filename, DRD64_MAX_PATH );
                if( 0x00 != i_result )  { continue; }
 
-               if( '\0' != *(pstr_pathname + 0) )      {
-                       i_result        = strncmp( pstr_pathname, p_srcfile->str_srcpath, DRD64_MAX_PATH );
-                       if( 0x00 != i_result )  { continue; }
-               }
+               if( NULL == pstr_path )
+                       { goto  goto_SrcFile_SearchSrcFile_post; }
 
-               goto    goto_SrcFile_SearchSrcFile_post;
+               if( '\0' == p_srcfile->str_srcpath[0] )
+                       { goto  goto_SrcFile_SearchSrcFile_post; }
+                       
+               i_result        = strncmp( pstr_path, p_srcfile->str_srcpath, DRD64_MAX_PATH );
+               if( 0x00 == i_result )
+                       { goto  goto_SrcFile_SearchSrcFile_post; }
        }
 
        p_srcfile       = NULL;
@@ -189,31 +191,27 @@ LIBGOBLIN_SRCFILE_EXTERN
 LibGoblin_SrcFile      *
        SrcFile_DispenseSrcFile(
                        LibGoblin_BinaryFile    *p_bfile,
-                       char    *pstr_filepath )
+                       char    *pstr_filename,
+                       char    *pstr_path )
 {
-       char    str_filename[DRD64_MAX_PATH + 1];
-       char    str_pathname[DRD64_MAX_PATH + 1];
        LibGoblin_SrcFile       *p_srcfile;
 
        assert( NULL != p_bfile );
 
-       strncpy( str_filename, pstr_filepath, DRD64_MAX_PATH );
-       basename( str_filename );
-
-       strncpy( str_pathname, pstr_filepath, DRD64_MAX_PATH );
-       dirname( str_pathname );
-       if(( '.' == str_pathname[0] ) && ( '\0' == str_pathname[1] ))
-               { str_pathname[0] = '\0'; }
-
-       p_srcfile       = SrcFile_SearchSrcFile( p_bfile, str_filename, str_pathname );
+       p_srcfile       = SrcFile_SearchSrcFile( p_bfile, pstr_filename, pstr_path );
        if( NULL == p_srcfile ) {
                p_srcfile       = SrcFile_AllocSrcFile( p_bfile );
        }
 
        assert( NULL != p_srcfile );
 
-       strncpy( p_srcfile->str_filename, str_filename, DRD64_MAX_PATH );
-       p_srcfile->dw_hash_filename     = Common_CalcDJBhash( str_filename );
+       strncpy( p_srcfile->str_filename, pstr_filename, DRD64_MAX_PATH );
+       p_srcfile->dw_hash_filename     = Common_CalcDJBhash( pstr_filename );
+
+       if( NULL == pstr_path )
+               { p_srcfile->str_srcpath[0]     = '\0'; }
+       else    
+               { strncpy( p_srcfile->str_srcpath, pstr_path, DRD64_MAX_PATH ); }
                                
        return  p_srcfile;
 }