~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/programs/winefile/splitpath.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Copyright 2000, 2004 Martin Fuchs
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 17  */
 18 
 19 #include "winefile.h"
 20 
 21 
 22 void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext)
 23 {
 24         const WCHAR* end; /* end of processed string */
 25         const WCHAR* p;   /* search pointer */
 26         const WCHAR* s;   /* copy pointer */
 27 
 28         /* extract drive name */
 29         if (path[0] && path[1]==':') {
 30                 if (drv) {
 31                         *drv++ = *path++;
 32                         *drv++ = *path++;
 33                         *drv = '\0';
 34                 }
 35         } else if (drv)
 36                 *drv = '\0';
 37 
 38         /* search for end of string or stream separator */
 39         for(end=path; *end && *end!=':'; )
 40                 end++;
 41 
 42         /* search for begin of file extension */
 43         for(p=end; p>path && *--p!='\\' && *p!='/'; )
 44                 if (*p == '.') {
 45                         end = p;
 46                         break;
 47                 }
 48 
 49         if (ext)
 50                 for(s=end; (*ext=*s++); )
 51                         ext++;
 52 
 53         /* search for end of directory name */
 54         for(p=end; p>path; )
 55                 if (*--p=='\\' || *p=='/') {
 56                         p++;
 57                         break;
 58                 }
 59 
 60         if (name) {
 61                 for(s=p; s<end; )
 62                         *name++ = *s++;
 63 
 64                 *name = '\0';
 65         }
 66 
 67         if (dir) {
 68                 for(s=path; s<p; )
 69                         *dir++ = *s++;
 70 
 71                 *dir = '\0';
 72         }
 73 }
 74 
 75 
 76 /*
 77 void main()     // test splipath()
 78 {
 79         WCHAR drv[_MAX_DRIVE+1], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT];
 80 
 81         _wsplitpath(L"x\\y", drv, dir, name, ext);
 82         _wsplitpath(L"x\\", drv, dir, name, ext);
 83         _wsplitpath(L"\\x", drv, dir, name, ext);
 84         _wsplitpath(L"x", drv, dir, name, ext);
 85         _wsplitpath(L"", drv, dir, name, ext);
 86         _wsplitpath(L".x", drv, dir, name, ext);
 87         _wsplitpath(L":x", drv, dir, name, ext);
 88         _wsplitpath(L"a:x", drv, dir, name, ext);
 89         _wsplitpath(L"a.b:x", drv, dir, name, ext);
 90         _wsplitpath(L"W:\\/\\abc/Z:~", drv, dir, name, ext);
 91         _wsplitpath(L"abc.EFGH:12345", drv, dir, name, ext);
 92         _wsplitpath(L"C:/dos/command.com", drv, dir, name, ext);
 93 }
 94 */
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.