src/hotspot/share/utilities/classpathStream.cpp
author stefank
Mon, 25 Nov 2019 12:33:15 +0100
changeset 59252 623722a6aeb9
parent 57897 e2e315f1aa63
permissions -rw-r--r--
8234740: Harmonize parameter order in Atomic - cmpxchg Reviewed-by: rehn, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57897
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     1
/*
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     4
 *
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     8
 *
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    13
 * accompanied this code).
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    14
 *
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    18
 *
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    21
 * questions.
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    22
 *
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    23
 */
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    24
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    25
#include "precompiled.hpp"
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    26
#include "memory/allocation.inline.hpp"
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    27
#include "runtime/os.hpp"
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    28
#include "utilities/classpathStream.hpp"
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    29
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    30
const char* ClasspathStream::get_next() {
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    31
  while (_class_path[_end] != '\0' && _class_path[_end] != os::path_separator()[0]) {
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    32
    _end++;
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    33
  }
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    34
  int path_len = _end - _start;
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    35
  char* path = NEW_RESOURCE_ARRAY(char, path_len + 1);
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    36
  strncpy(path, &_class_path[_start], path_len);
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    37
  path[path_len] = '\0';
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    38
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    39
  while (_class_path[_end] == os::path_separator()[0]) {
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    40
    _end++;
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    41
  }
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    42
  _start = _end;
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    43
  return path;
e2e315f1aa63 8230168: Use ClasspathStream for FileMapInfo::create_path_array
iklam
parents:
diff changeset
    44
}