mf_loadpath.c
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This library is free software; you can redistribute it and/or
  4.    modify it under the terms of the GNU Library General Public
  5.    License as published by the Free Software Foundation; either
  6.    version 2 of the License, or (at your option) any later version.
  7.    
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU Library General Public
  14.    License along with this library; if not, write to the Free
  15.    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16.    MA 02111-1307, USA */
  17. #include "mysys_priv.h"
  18. #include <m_string.h>
  19. /* Returns full load-path for a file. to may be = path */
  20. /* if path is a hard-path return path */
  21. /* if path starts with home-dir return path */
  22. /* if path starts with current dir or parent-dir unpack path */
  23. /* if there is no path, prepend with own_path_prefix if given */
  24. /* else unpack path according to current dir */
  25. my_string my_load_path(my_string to, const char *path,
  26.        const char *own_path_prefix)
  27. {
  28.   char buff[FN_REFLEN];
  29.   DBUG_ENTER("my_load_path");
  30.   DBUG_PRINT("enter",("path: %s  prefix: %s",path,
  31.       own_path_prefix ? own_path_prefix : ""));
  32.   if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) ||
  33.       test_if_hard_path(path))
  34.     VOID(strmov(buff,path));
  35.   else if ((path[0] == FN_CURLIB && path[1] == FN_LIBCHAR) ||
  36.    (is_prefix((gptr) path,FN_PARENTDIR) &&
  37.     path[strlen(FN_PARENTDIR)] == FN_LIBCHAR) ||
  38.    ! own_path_prefix)
  39.   {
  40.     if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)),MYF(0)))
  41.       VOID(strcat(buff,path));
  42.     else
  43.       VOID(strmov(buff,path));
  44.   }
  45.   else
  46.     VOID(strxmov(buff,own_path_prefix,path,NullS));
  47.   strmov(to,buff);
  48.   DBUG_PRINT("exit",("to: %s",to));
  49.   DBUG_RETURN(to);
  50. } /* my_load_path */