home *** CD-ROM | disk | FTP | other *** search
- @echo off
- REM PathAdd.bat - add a directory to the current path, if it's not already there
-
- if "%1"=="" GOTO SHOW_HOW
- if not "%2"=="" GOTO SHOW_HOW
- cenvi %0.BAT %1
- GOTO FINI
-
- :SHOW_HOW
- ECHO PathAdd.bat - Add a directory to the PATH if it's not already there
- ECHO USAGE: PathBat DirSpec
- GOTO FINI
-
-
- GOTO CENVI_EXIT
-
- main(argc,argv)
- {
- NewDir = argv[1]
- if ( AlreadyInPath(NewDir) ) {
- printf("The Directory \"%s\" is already in PATH.\n",NewDir)
- } else {
- // File is not already in the path, and so append to the end of PATH.
- // If there isn't a semi-colon at the end of PATH already, then add one.
- if ( PATH[strlen(PATH)-1] != ';' )
- strcat(PATH,";")
- // Append this new directory to the end of the path statement
- strcat(PATH,NewDir)
- }
- }
-
- AlreadyInPath(Dir) // search through path for this Dir, return True if found, else False
- {
- len = strlen(Dir)
- p = PATH
- do {
- if ( 0 == strnicmp(p,Dir,len) && (p[len]==0 || p[len]==';') )
- return(True)
- p = strchr(p,';')
- } while( p++ != NULL )
- return(False)
- }
-
- :CENVI_EXIT
- :FINI