From 1c640bebb637abfe6d2ddb21897e6c49ddfd8e9a Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 4 Apr 2014 16:41:55 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11703 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/input.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 25ed28a66c..e8f325b612 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -51,6 +51,10 @@ #include "omp.h" #endif +#ifdef _WIN32 +#include +#endif + using namespace LAMMPS_NS; #define DELTALINE 256 @@ -182,7 +186,10 @@ void Input::file() if (n == 0) { if (label_active) error->all(FLERR,"Label wasn't found in input script"); if (me == 0) { - if (infile != stdin) fclose(infile); + if (infile != stdin) { + fclose(infile); + infile = NULL; + } nfile--; } MPI_Bcast(&nfile,1,MPI_INT,0,world); @@ -231,11 +238,12 @@ void Input::file(const char *filename) // error if another nested file still open, should not be possible // open new filename and set infile, infiles[0], nfile // call to file() will close filename and decrement nfile - + if (me == 0) { if (nfile > 1) error->one(FLERR,"Invalid use of library file() function"); - + + if (infile && infile != stdin) fclose(infile); infile = fopen(filename,"r"); if (infile == NULL) { char str[128]; @@ -815,7 +823,7 @@ void Input::jump() if (me == 0) { if (strcmp(arg[0],"SELF") == 0) rewind(infile); else { - if (infile != stdin) fclose(infile); + if (infile && infile != stdin) fclose(infile); infile = fopen(arg[0],"r"); if (infile == NULL) { char str[128]; @@ -985,11 +993,14 @@ void Input::shell() } else if (strcmp(arg[0],"mkdir") == 0) { if (narg < 2) error->all(FLERR,"Illegal shell mkdir command"); -#if !defined(WINDOWS) && !defined(__MINGW32__) if (me == 0) - for (int i = 1; i < narg; i++) + for (int i = 1; i < narg; i++) { +#if defined(_WIN32) + _mkdir(arg[i]); +#else mkdir(arg[i], S_IRWXU | S_IRGRP | S_IXGRP); #endif + } } else if (strcmp(arg[0],"mv") == 0) { if (narg != 3) error->all(FLERR,"Illegal shell mv command");