mf_dirname.c
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:4k
- /* Copyright (C) 2000 MySQL AB
- This program 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.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
- #include "mysys_priv.h"
- #include <m_string.h>
- /* Functions definied in this file */
- uint dirname_length(const char *name)
- {
- register my_string pos,gpos;
- #ifdef BASKSLASH_MBTAIL
- CHARSET_INFO *fs= fs_character_set();
- #endif
- #ifdef FN_DEVCHAR
- if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
- #endif
- pos=(char*) name-1;
- gpos= pos++;
- for ( ; *pos ; pos++) /* Find last FN_LIBCHAR */
- {
- #ifdef BASKSLASH_MBTAIL
- uint l;
- if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3)))
- {
- pos+= l - 1;
- continue;
- }
- #endif
- if (*pos == FN_LIBCHAR || *pos == '/'
- #ifdef FN_C_AFTER_DIR
- || *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2
- #endif
- )
- gpos=pos;
- }
- return ((uint) (uint) (gpos+1-(char*) name));
- }
- /* Gives directory part of filename. Directory ends with '/' */
- /* Returns length of directory part */
- uint dirname_part(my_string to, const char *name)
- {
- uint length;
- DBUG_ENTER("dirname_part");
- DBUG_PRINT("enter",("'%s'",name));
- length=dirname_length(name);
- convert_dirname(to, name, name+length);
- DBUG_RETURN(length);
- } /* dirname */
- /*
- Convert directory name to use under this system
- SYNPOSIS
- convert_dirname()
- to Store result here
- from Original filename
- from_end Pointer at end of filename (normally end