From e611b132f9b8abe35b362e5870b74bce94a1e58e Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 May 2020 20:51:50 -0700 Subject: initial commit --- private/mvdm/softpc.new/rename/rename.c | 100 ++++++++++++++++++++++++++++++++ private/mvdm/softpc.new/rename/sources | 55 ++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 private/mvdm/softpc.new/rename/rename.c create mode 100644 private/mvdm/softpc.new/rename/sources (limited to 'private/mvdm/softpc.new/rename') diff --git a/private/mvdm/softpc.new/rename/rename.c b/private/mvdm/softpc.new/rename/rename.c new file mode 100644 index 000000000..e26c43306 --- /dev/null +++ b/private/mvdm/softpc.new/rename/rename.c @@ -0,0 +1,100 @@ + +/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Include files */ + +#include "windows.h" + +#include "stdio.h" +#include "stdlib.h" +#include "string.h" + +#define MAX_NAME_SIZE (8) +#define MAX_EXT_SIZE (3) + +char CharRemoveList[] = "AEIOUaeiou_"; + +int ConvertFileName(char *NameToConvert); + +/*:::::::::::::::::::::::::::::::::::::::::::::::::::::: Main entry point */ + +_CRTAPI1 main(int argc, char *argv[]) +{ + int index; + + /*......................................... Validate input parameters */ + + if(argc < 2) + { + printf("Invalid usage : rename \n"); + return(1); + } + + + for(index = 1; index < argc; index++) + ConvertFileName(argv[index]); + + return(0); +} + + +/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */ + +int ConvertFileName(char *NameToConvert) +{ + char *Name, *Ext, *ExtStart; + int NameSize, ExtSize; + char NewName[MAX_NAME_SIZE+1], NewFileName[1000]; + char *NewNamePtr; + + /*....................... Get the size of the file name and extension */ + + for(Name = NameToConvert, NameSize = 0; + *Name && *Name != '.'; Name++, NameSize++); + + for(ExtStart = Name, Ext = *Name == '.' ? Name+1 : Name, ExtSize = 0; + *Ext ; Ext++, ExtSize++); + + /*................................ Validate name and extension sizes */ + + if(ExtSize > MAX_EXT_SIZE) + { + printf("Unable to convert '%s' to 8.3 filename\n", NameToConvert); + return(1); + } + + + if(NameSize <= MAX_NAME_SIZE) + { + /* Name does not need conversion */ + return(0); + } + + /*................................................ Convert file name */ + + NewNamePtr = &NewName[MAX_NAME_SIZE]; + *NewNamePtr-- = 0; + + do + { + Name--; + + if(NameSize > MAX_NAME_SIZE && strchr(CharRemoveList, *Name)) + NameSize--; /* Remove character */ + else + *NewNamePtr-- = *Name; + } + while(NewNamePtr >= NewName && Name != NameToConvert); + + /*............................................. Validate conversion */ + + if(NameSize > MAX_NAME_SIZE) + { + printf("Unable to convert '%s' to 8.3 filename\n", NameToConvert); + return(1); + } + + sprintf(NewFileName,"%s%s", NewNamePtr+1, ExtStart); + printf("REN '%s' to '%s'\n", NameToConvert, NewFileName); + rename(NameToConvert, NewFileName); + + return(0); +} diff --git a/private/mvdm/softpc.new/rename/sources b/private/mvdm/softpc.new/rename/sources new file mode 100644 index 000000000..79e7e7095 --- /dev/null +++ b/private/mvdm/softpc.new/rename/sources @@ -0,0 +1,55 @@ +!IF 0 + +!IF $(ALPHA) +GPSIZE=0 +!ELSE +GPSIZE=32 +!ENDIF + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Steve Wood (stevewo) 12-Apr-1990 + +NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl + +!ENDIF + + +MAJORCOMP=spc +MINORCOMP=rename +TARGETNAME=rename +TARGETPATH=$(SOFTPC_ROOT)\rename\obj + + + +# Pick one of the following and delete the others +TARGETTYPE=PROGRAM + +TARGETLIBS= + +SOURCES=rename.c + +LINKLIBS= $(BASEDIR)\public\sdk\lib\*\setargv.obj + + +NTTEST= + +UMTYPE=console +UMTEST= +UMAPPL= +UMBASE=0x1000000 +UMLIBS= -- cgit v1.2.3