jdk/src/share/bin/wildcard.c
changeset 13411 224a28370893
parent 7668 d4a77089c587
child 14517 e50acb436a8d
equal deleted inserted replaced
13410:e667545511c7 13411:224a28370893
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   127 struct WildcardIterator_
   127 struct WildcardIterator_
   128 {
   128 {
   129     HANDLE handle;
   129     HANDLE handle;
   130     char *firstFile; /* Stupid FindFirstFile...FindNextFile */
   130     char *firstFile; /* Stupid FindFirstFile...FindNextFile */
   131 };
   131 };
   132 
   132 // since this is used repeatedly we keep it here.
       
   133 static WIN32_FIND_DATA find_data;
   133 static WildcardIterator
   134 static WildcardIterator
   134 WildcardIterator_for(const char *wildcard)
   135 WildcardIterator_for(const char *wildcard)
   135 {
   136 {
   136     WIN32_FIND_DATA find_data;
       
   137     WildcardIterator it = NEW_(WildcardIterator);
   137     WildcardIterator it = NEW_(WildcardIterator);
   138     HANDLE handle = FindFirstFile(wildcard, &find_data);
   138     HANDLE handle = FindFirstFile(wildcard, &find_data);
   139     if (handle == INVALID_HANDLE_VALUE)
   139     if (handle == INVALID_HANDLE_VALUE)
   140         return NULL;
   140         return NULL;
   141     it->handle = handle;
   141     it->handle = handle;
   144 }
   144 }
   145 
   145 
   146 static char *
   146 static char *
   147 WildcardIterator_next(WildcardIterator it)
   147 WildcardIterator_next(WildcardIterator it)
   148 {
   148 {
   149     WIN32_FIND_DATA find_data;
       
   150     if (it->firstFile != NULL) {
   149     if (it->firstFile != NULL) {
   151         char *firstFile = it->firstFile;
   150         char *firstFile = it->firstFile;
   152         it->firstFile = NULL;
   151         it->firstFile = NULL;
   153         return firstFile;
   152         return firstFile;
   154     }
   153     }
   410         return classpath;
   409         return classpath;
   411     fl = FileList_split(classpath, PATH_SEPARATOR);
   410     fl = FileList_split(classpath, PATH_SEPARATOR);
   412     FileList_expandWildcards(fl);
   411     FileList_expandWildcards(fl);
   413     expanded = FileList_join(fl, PATH_SEPARATOR);
   412     expanded = FileList_join(fl, PATH_SEPARATOR);
   414     FileList_free(fl);
   413     FileList_free(fl);
   415     if (getenv("_JAVA_LAUNCHER_DEBUG") != 0)
   414     if (getenv(JLDEBUG_ENV_ENTRY) != 0)
   416         printf("Expanded wildcards:\n"
   415         printf("Expanded wildcards:\n"
   417                "    before: \"%s\"\n"
   416                "    before: \"%s\"\n"
   418                "    after : \"%s\"\n",
   417                "    after : \"%s\"\n",
   419                classpath, expanded);
   418                classpath, expanded);
   420     return expanded;
   419     return expanded;