ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

splitp.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Kernel
00003  * LICENSE:         BSD - See COPYING.ARM in the top level directory
00004  * PURPOSE:         CRT: implementation of _splitpath / _wsplitpath
00005  * PROGRAMMERS:     Timo Kreuzer
00006  */
00007 
00008 #include <precomp.h>
00009 #include <tchar.h>
00010 
00011 /*
00012  * @implemented
00013  */
00014 void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname, _TCHAR* ext)
00015 {
00016     const _TCHAR *src, *dir_start, *file_start = 0, *ext_start = 0;
00017 
00018     /* Truncate all output strings */
00019     if (drive) drive[0] = '\0';
00020     if (dir) dir[0] = '\0';
00021     if (fname) fname[0] = '\0';
00022     if (ext) ext[0] = '\0';
00023 
00024 #if WINVER >= 0x600
00025     /* Check parameter */
00026     if (!path)
00027     {
00028 #ifndef _LIBCNT_
00029         _set_errno(EINVAL);
00030 #endif
00031         return;
00032     }
00033 #endif
00034 
00035 #if WINVER == 0x600
00036     /* Skip '\\?\' prefix */
00037     if ((path[0] == '\\') && (path[1] == '\\') &&
00038         (path[2] == '?') && (path[3] == '\\')) path += 4;
00039 #endif
00040 
00041     if (path[0] == '\0') return;
00042 
00043     /* Check if we have a drive letter (only 1 char supported) */
00044     if (path[1] == ':')
00045     {
00046         if (drive)
00047         {
00048             drive[0] = path[0];
00049             drive[1] = ':';
00050             drive[2] = '\0';
00051         }
00052         path += 2;
00053     }
00054 
00055     /* Scan the rest of the string */
00056     dir_start = path;
00057     while (*path != '\0')
00058     {
00059         /* Remember last path seperator and last dot */
00060         if ((*path == '\\') || (*path == '/')) file_start = path + 1;
00061         if (*path == '.') ext_start = path;
00062         path++;
00063     }
00064 
00065     /* Check if we got a file name / extension */
00066     if (!file_start)
00067         file_start = dir_start;
00068     if (!ext_start || ext_start < file_start)
00069         ext_start = path;
00070 
00071     if (dir)
00072     {
00073         src = dir_start;
00074         while (src < file_start) *dir++ = *src++;
00075         *dir = '\0';
00076     }
00077 
00078     if (fname)
00079     {
00080         src = file_start;
00081         while (src < ext_start) *fname++ = *src++;
00082         *fname = '\0';
00083     }
00084 
00085     if (ext)
00086     {
00087         src = ext_start;
00088         while (*src != '\0') *ext++ = *src++;
00089         *ext = '\0';
00090     }
00091 }
00092 

Generated on Fri May 25 2012 04:35:10 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.