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

rdel.c
Go to the documentation of this file.
00001 /*  $Id: rdel.c 29690 2007-10-19 23:21:45Z dreimer $
00002  * COPYRIGHT:             See COPYING in the top level directory
00003  * PROGRAMMER:            Rex Jolliff (rex@lvcablemodem.com)
00004  * PURPOSE:               Platform independant delete command
00005  */
00006 
00007 #include <dirent.h>
00008 #include <errno.h>
00009 #include <limits.h>
00010 #include <stdio.h>
00011 #include <string.h>
00012 #include <stdlib.h>
00013 
00014 void
00015 convertPath (char * pathToConvert)
00016 {
00017   while (*pathToConvert != 0)
00018   {
00019     if (*pathToConvert == '\\')
00020     {
00021       *pathToConvert = '/';
00022     }
00023     pathToConvert++;
00024   }
00025 }
00026 
00027 void
00028 getDirectory (const char *filename, char * directorySpec)
00029 {
00030   int  lengthOfDirectory;
00031 
00032   if (strrchr (filename, '/') != 0)
00033   {
00034     lengthOfDirectory = strrchr (filename, '/') - filename;
00035     strncpy (directorySpec, filename, lengthOfDirectory);
00036     directorySpec [lengthOfDirectory] = '\0';
00037   }
00038   else
00039   {
00040     strcpy (directorySpec, ".");
00041   }
00042 }
00043 
00044 void
00045 getFilename (const char *filename, char * fileSpec)
00046 {
00047   if (strrchr (filename, '/') != 0)
00048   {
00049     strcpy (fileSpec, strrchr (filename, '/') + 1);
00050   }
00051   else
00052   {
00053     strcpy (fileSpec, filename);
00054   }
00055 }
00056 
00057 int
00058 main (int argc, char* argv[])
00059 {
00060   int  justPrint = 0;
00061   int  idx;
00062   int  returnCode;
00063 
00064   for (idx = 1; idx < argc; idx++)
00065   {
00066     convertPath (argv [idx]);
00067 
00068     if (justPrint)
00069     {
00070       printf ("delete %s\n", argv [idx]);
00071     }
00072     else
00073     {
00074       returnCode = remove (argv [idx]);
00075       if (returnCode != 0 && errno != ENOENT)
00076       {
00077       /* Continue even if there is errors */
00078 #if 0
00079         printf ("Unlink of %s failed.  Unlink returned %d.\n",
00080                 argv [idx],
00081                 returnCode);
00082         return  returnCode;
00083 #endif
00084       }
00085     }
00086   }
00087 
00088   return  0;
00089 }
00090 
00091 

Generated on Mon May 28 2012 04:19:04 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.