Commit 5e84b1dc authored by Kitware Robot's avatar Kitware Robot Committed by Brad King

KWSys 2016-11-08 (2b3e2b1c)

Code extracted from:

    http://public.kitware.com/KWSys.git

at commit 2b3e2b1c28e676a1f4eb951104a1265a91c4df8c (master).

Upstream Shortlog
-----------------

Brad King (12):
      15e90a3c Sort includes to stabilize include order w.r.t. clang-format
      26509227 Copyright.txt: Add notice of copyright by contributors
      fc42d3f2 Add temporary script to filter license notices
      c41c1bc4 Simplify KWSys per-source license notices
      1d4c0b4a Remove temporary script that filtered license notices
      a4f5ef79 SystemInformation: Remove stray comment
      8649a886 kwsysPrivate: Protect KWSYS_HEADER macro from clang-format
      89b98af5 Configure clang-format for KWSys source tree
      547dacad Add a script to run clang-format on the entire source tree
      aa94be0c CONTRIBUTING: Add a section on coding style
      6604c4b6 Empty commit at end of history preceding clang-format style transition
      2b3e2b1c Tell Git to not export 'clang-format' infrastructure

Kitware Robot (1):
      6c973b46 Revise C++ coding style using clang-format
parent 62b9eb5b
......@@ -3,6 +3,8 @@
/GitSetup export-ignore
/SetupForDevelopment.sh export-ignore eol=lf
/clang-format.bash export-ignore eol=lf
/.clang-format export-ignore
/CONTRIBUTING.rst conflict-marker-size=78
......
This diff is collapsed.
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef @KWSYS_NAMESPACE@_Base64_h
#define @KWSYS_NAMESPACE@_Base64_h
......@@ -21,41 +12,40 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsysBase64 kwsys_ns(Base64)
# define kwsysBase64_Decode kwsys_ns(Base64_Decode)
# define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
# define kwsysBase64_Encode kwsys_ns(Base64_Encode)
# define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
# define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
# define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
#define kwsysBase64 kwsys_ns(Base64)
#define kwsysBase64_Decode kwsys_ns(Base64_Decode)
#define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
#define kwsysBase64_Encode kwsys_ns(Base64_Encode)
#define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
#define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
#define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
#endif
#if defined(__cplusplus)
extern "C"
{
extern "C" {
#endif
/**
* Encode 3 bytes into a 4 byte string.
*/
kwsysEXPORT void kwsysBase64_Encode3(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT void kwsysBase64_Encode3(const unsigned char* src,
unsigned char* dest);
/**
* Encode 2 bytes into a 4 byte string.
*/
kwsysEXPORT void kwsysBase64_Encode2(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT void kwsysBase64_Encode2(const unsigned char* src,
unsigned char* dest);
/**
* Encode 1 bytes into a 4 byte string.
*/
kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT void kwsysBase64_Encode1(const unsigned char* src,
unsigned char* dest);
/**
* Encode 'length' bytes from the input buffer and store the encoded
......@@ -70,17 +60,16 @@ kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
* the extra padding needed to complete the encode 4 bytes will stop
* the decoding anyway).
*/
kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char *input,
size_t length,
unsigned char *output,
kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char* input,
size_t length, unsigned char* output,
int mark_end);
/**
* Decode 4 bytes into a 3 byte string. Returns the number of bytes
* actually decoded.
*/
kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
unsigned char *dest);
kwsysEXPORT int kwsysBase64_Decode3(const unsigned char* src,
unsigned char* dest);
/**
* Decode bytes from the input buffer and store the decoded stream
......@@ -94,9 +83,8 @@ kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
* much decoded data to expect (of course, the buffer must be large
* enough).
*/
kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char *input,
size_t length,
unsigned char *output,
kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char* input,
size_t length, unsigned char* output,
size_t max_input_length);
#if defined(__cplusplus)
......@@ -106,17 +94,17 @@ kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char *input,
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
# undef kwsys_ns
# undef kwsysEXPORT
# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# undef kwsysBase64
# undef kwsysBase64_Decode
# undef kwsysBase64_Decode3
# undef kwsysBase64_Encode
# undef kwsysBase64_Encode1
# undef kwsysBase64_Encode2
# undef kwsysBase64_Encode3
# endif
#undef kwsys_ns
#undef kwsysEXPORT
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
#undef kwsysBase64
#undef kwsysBase64_Decode
#undef kwsysBase64_Decode3
#undef kwsysBase64_Encode
#undef kwsysBase64_Encode1
#undef kwsysBase64_Encode2
#undef kwsysBase64_Encode3
#endif
#endif
#endif
#=============================================================================
# KWSys - Kitware System Library
# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing#kwsys for details.
# The Kitware System Library is intended to be included in other
# projects. It is completely configurable in that the library's
......
......@@ -24,6 +24,19 @@ KWSys has no independent issue tracker. After encountering an issue
Otherwise please report the issue to the tracker for the project that
hosts the copy of KWSys in which the problem was found.
Code Style
==========
We use `clang-format`_ to define our style for C++ code in the KWSys source
tree. See the `.clang-format`_ configuration file for our style settings.
Use ``clang-format`` version 3.8 or higher to format source files.
See also the `clang-format.bash`_ script.
.. _`clang-format`: http://clang.llvm.org/docs/ClangFormat.html
.. _`.clang-format`: .clang-format
.. _`clang-format.bash`: clang-format.bash
License
=======
......
#=============================================================================
# KWSys - Kitware System Library
# Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing#kwsys for details.
set(CTEST_PROJECT_NAME "KWSys")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
set(CTEST_DROP_METHOD "http")
......
This diff is collapsed.
This diff is collapsed.
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef @KWSYS_NAMESPACE@_Configure_h
#define @KWSYS_NAMESPACE@_Configure_h
......@@ -16,22 +7,22 @@
namespace. When not building a kwsys source file these macros are
temporarily defined inside the headers that use them. */
#if defined(KWSYS_NAMESPACE)
# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
/* Disable some warnings inside kwsys source files. */
#if defined(KWSYS_NAMESPACE)
# if defined(__BORLANDC__)
# pragma warn -8027 /* function not inlined. */
# endif
# if defined(__INTEL_COMPILER)
# pragma warning (disable: 1572) /* floating-point equality test */
# endif
# if defined(__sgi) && !defined(__GNUC__)
# pragma set woff 3970 /* pointer to int conversion */
# pragma set woff 3968 /* 64 bit conversion */
# endif
#if defined(__BORLANDC__)
#pragma warn - 8027 /* function not inlined. */
#endif
#if defined(__INTEL_COMPILER)
#pragma warning(disable : 1572) /* floating-point equality test */
#endif
#if defined(__sgi) && !defined(__GNUC__)
#pragma set woff 3970 /* pointer to int conversion */
#pragma set woff 3968 /* 64 bit conversion */
#endif
#endif
/* Whether kwsys namespace is "kwsys". */
......@@ -42,84 +33,84 @@
/* Whether Large File Support is available. */
#if @KWSYS_NAMESPACE@_LFS_REQUESTED
# define @KWSYS_NAMESPACE@_LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
#define @KWSYS_NAMESPACE@_LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
#endif
/* Setup Large File Support if requested. */
#if @KWSYS_NAMESPACE@_LFS_REQUESTED
/* Since LFS is requested this header must be included before system
headers whether or not LFS is available. */
# if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
# error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
# endif
/* Enable the large file API if it is available. */
# if @KWSYS_NAMESPACE@_LFS_AVAILABLE && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINES)
# if !defined(_LARGEFILE_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE_SOURCE)
# define _LARGEFILE_SOURCE
# endif
# if !defined(_LARGEFILE64_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE64_SOURCE)
# define _LARGEFILE64_SOURCE
# endif
# if !defined(_LARGE_FILES) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGE_FILES)
# define _LARGE_FILES
# endif
# if !defined(_FILE_OFFSET_BITS) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_FILE_OFFSET_BITS)
# define _FILE_OFFSET_BITS 64
# endif
# if 0 && (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64)
# error "_FILE_OFFSET_BITS must be defined to at least 64"
# endif
# endif
/* Since LFS is requested this header must be included before system
headers whether or not LFS is available. */
#if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
#error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
#endif
/* Enable the large file API if it is available. */
#if @KWSYS_NAMESPACE@_LFS_AVAILABLE && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINES)
#if !defined(_LARGEFILE_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE_SOURCE)
#define _LARGEFILE_SOURCE
#endif
#if !defined(_LARGEFILE64_SOURCE) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE64_SOURCE)
#define _LARGEFILE64_SOURCE
#endif
#if !defined(_LARGE_FILES) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGE_FILES)
#define _LARGE_FILES
#endif
#if !defined(_FILE_OFFSET_BITS) && \
!defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_FILE_OFFSET_BITS)
#define _FILE_OFFSET_BITS 64
#endif
#if 0 && (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64)
#error "_FILE_OFFSET_BITS must be defined to at least 64"
#endif
#endif
#endif
/* Setup the export macro. */
#if @KWSYS_BUILD_SHARED@
# if defined(_WIN32) || defined(__CYGWIN__)
# if defined(@KWSYS_NAMESPACE@_EXPORTS)
# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport)
# else
# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport)
# endif
# elif __GNUC__ >= 4
# define @KWSYS_NAMESPACE@_EXPORT __attribute__ ((visibility("default")))
# else
# define @KWSYS_NAMESPACE@_EXPORT
# endif
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(@KWSYS_NAMESPACE@_EXPORTS)
#define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport)
#else
#define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport)
#endif
#elif __GNUC__ >= 4
#define @KWSYS_NAMESPACE@_EXPORT __attribute__((visibility("default")))
#else
#define @KWSYS_NAMESPACE@_EXPORT
#endif
#else
# define @KWSYS_NAMESPACE@_EXPORT
#define @KWSYS_NAMESPACE@_EXPORT
#endif
/* Enable warnings that are off by default but are useful. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_ENABLE)
# if defined(_MSC_VER)
# pragma warning ( default : 4263 ) /* no override, call convention differs */
# endif
#if defined(_MSC_VER)
#pragma warning(default : 4263) /* no override, call convention differs */
#endif
#endif
/* Disable warnings that are on by default but occur in valid code. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_DISABLE)
# if defined(_MSC_VER)
# pragma warning (disable: 4097) /* typedef is synonym for class */
# pragma warning (disable: 4127) /* conditional expression is constant */
# pragma warning (disable: 4244) /* possible loss in conversion */
# pragma warning (disable: 4251) /* missing DLL-interface */
# pragma warning (disable: 4305) /* truncation from type1 to type2 */
# pragma warning (disable: 4309) /* truncation of constant value */
# pragma warning (disable: 4514) /* unreferenced inline function */
# pragma warning (disable: 4706) /* assignment in conditional expression */
# pragma warning (disable: 4710) /* function not inlined */
# pragma warning (disable: 4786) /* identifier truncated in debug info */
# endif
# if defined(__BORLANDC__) && !defined(__cplusplus)
/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
unused parameter using "(param)" syntax (i.e. no cast to void). */
# pragma warn -8019
# endif
#if defined(_MSC_VER)
#pragma warning(disable : 4097) /* typedef is synonym for class */
#pragma warning(disable : 4127) /* conditional expression is constant */
#pragma warning(disable : 4244) /* possible loss in conversion */
#pragma warning(disable : 4251) /* missing DLL-interface */
#pragma warning(disable : 4305) /* truncation from type1 to type2 */
#pragma warning(disable : 4309) /* truncation of constant value */
#pragma warning(disable : 4514) /* unreferenced inline function */
#pragma warning(disable : 4706) /* assignment in conditional expression */
#pragma warning(disable : 4710) /* function not inlined */
#pragma warning(disable : 4786) /* identifier truncated in debug info */
#endif
#if defined(__BORLANDC__) && !defined(__cplusplus)
/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
unused parameter using "(param)" syntax (i.e. no cast to void). */
#pragma warn - 8019
#endif
#endif
/* MSVC 6.0 in release mode will warn about code it produces with its
......@@ -127,10 +118,10 @@
configuration. Real warnings will be revealed by a debug build or
by other compilers. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_DISABLE_BOGUS)
# if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG)
# pragma warning ( disable : 4701 ) /* Variable may be used uninitialized. */
# pragma warning ( disable : 4702 ) /* Unreachable code. */
# endif
#if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG)
#pragma warning(disable : 4701) /* Variable may be used uninitialized. */
#pragma warning(disable : 4702) /* Unreachable code. */
#endif
#endif
#endif
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef @KWSYS_NAMESPACE@_Configure_hxx
#define @KWSYS_NAMESPACE@_Configure_hxx
......@@ -18,17 +9,19 @@
/* Whether wstring is available. */
#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@
/* Whether <ext/stdio_filebuf.h> is available. */
#define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H @KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
#define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
/* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys @KWSYS_NAMESPACE@
# endif
# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
# define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
#define kwsys @KWSYS_NAMESPACE@
#endif
#define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
#define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
#define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
#endif
#endif
This diff is collapsed.
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Copyright 2000-2016 Kitware, Inc. and Contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -13,10 +13,9 @@ are met:
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of Kitware, Inc., the Insight Software Consortium,
nor the names of their contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
* Neither the name of Kitware, Inc. nor the names of Contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
......@@ -29,3 +28,11 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
The following individuals and institutions are among the Contributors:
* Insight Software Consortium <insightsoftwareconsortium.org>
See version control history for details of individual contributions.
/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#include "kwsysPrivate.h"
#include KWSYS_HEADER(Directory.hxx)
......@@ -19,16 +10,15 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "Directory.hxx.in"
# include "Configure.hxx.in"
# include "Encoding.hxx.in"
#include "Configure.hxx.in"
#include "Directory.hxx.in"
#include "Encoding.hxx.in"
#endif
#include <string>
#include <vector>
namespace KWSYS_NAMESPACE
{
namespace KWSYS_NAMESPACE {
//----------------------------------------------------------------------------
class DirectoryInternals
......@@ -62,10 +52,9 @@ unsigned long Directory::GetNumberOfFiles() const
//----------------------------------------------------------------------------
const char* Directory::GetFile(unsigned long dindex) const
{
if ( dindex >= this->Internal->Files.size() )
{
if (dindex >= this->Internal->Files.size()) {
return 0;
}
}
return this->Internal->Files[dindex].c_str();
}
......@@ -88,9 +77,10 @@ void Directory::Clear()
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#include <io.h>
#include <ctype.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -99,15 +89,14 @@ void Directory::Clear()
// Wide function names can vary depending on compiler:
#ifdef __BORLANDC__
# define _wfindfirst_func __wfindfirst
# define _wfindnext_func __wfindnext
#define _wfindfirst_func __wfindfirst
#define _wfindnext_func __wfindnext
#else
# define _wfindfirst_func _wfindfirst
# define _wfindnext_func _wfindnext
#define _wfindfirst_func _wfindfirst
#define _wfindnext_func _wfindnext
#endif
namespace KWSYS_NAMESPACE
{
namespace KWSYS_NAMESPACE {
bool Directory::Load(const std::string& name)
{
......@@ -120,42 +109,34 @@ bool Directory::Load(const std::string& name)
#endif
char* buf;
size_t n = name.size();
if ( *name.rbegin() == '/' || *name.rbegin() == '\\' )
{
if (*name.rbegin() == '/' || *name.rbegin() == '\\') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
}
else
{
} else {
// Make sure the slashes in the wildcard suffix are consistent with the
// rest of the path
buf = new char[n + 2 + 1];
if ( name.find('\\') != name.npos )
{
if (name.find('\\') != name.npos) {
sprintf(buf, "%s\\*", name.c_str());
}
else
{
} else {
sprintf(buf, "%s/*", name.c_str());
}
}
struct _wfinddata_t data; // data of current file
}
struct _wfinddata_t data; // data of current file
// Now put them into the file array
srchHandle = _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete [] buf;
srchHandle =
_wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete[] buf;
if ( srchHandle == -1 )
{
if (srchHandle == -1) {
return 0;
}
}
// Loop through names
do
{
do {
this->Internal->Files.push_back(Encoding::ToNarrow(data.name));
}
while ( _wfindnext_func(srchHandle, &data) != -1 );
} while (_wfindnext_func(srchHandle, &data) != -1);
this->Internal->Path = name;
return _findclose(srchHandle) != -1;
}
......@@ -170,34 +151,29 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
#endif
char* buf;
size_t n = name.size();
if ( *name.rbegin() == '/' )
{
if (*name.rbegin() == '/') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
}
else
{
} else {
buf = new char[n + 2 + 1];
sprintf(buf, "%s/*", name.c_str());
}
struct _wfinddata_t data; // data of current file
}
struct _wfinddata_t data; // data of current file
// Now put them into the file array
srchHandle = _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete [] buf;
srchHandle =
_wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
delete[] buf;
if ( srchHandle == -1 )
{
if (srchHandle == -1) {
return 0;
}
}
// Loop through names
unsigned long count = 0;
do
{
do {
count++;
}
while ( _wfindnext_func(srchHandle, &data) != -1 );
} while (_wfindnext_func(srchHandle, &data) != -1);
_findclose(srchHandle);
return count;
}
......@@ -209,6 +185,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
// Now the POSIX style directory access
#include <sys/types.h>
#include <dirent.h>
// PGI with glibc has trouble with dirent and large file support:
......@@ -216,33 +193,30 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
// p=1992&sid=f16167f51964f1a68fe5041b8eb213b6
// Work around the problem by mapping dirent the same way as readdir.
#if defined(__PGI) && defined(__GLIBC__)
# define kwsys_dirent_readdir dirent
# define kwsys_dirent_readdir64 dirent64
# define kwsys_dirent kwsys_dirent_lookup(readdir)
# define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
# define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
#define kwsys_dirent_readdir dirent
#define kwsys_dirent_readdir64 dirent64
#define kwsys_dirent kwsys_dirent_lookup(readdir)
#define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
#define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
#else
# define kwsys_dirent dirent
#define kwsys_dirent dirent
#endif
namespace KWSYS_NAMESPACE
{
namespace KWSYS_NAMESPACE {
bool Directory::Load(const std::string& name)
{
this->Clear();
DIR* dir = opendir(name.c_str());
if (!dir)
{
if (!dir) {
return 0;
}
}
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) )
{
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
this->Internal->Files.push_back(d->d_name);
}
}
this->Internal->Path = name;
closedir(dir);
return 1;
......@@ -252,16 +226,14 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
{
DIR* dir = opendir(name.c_str());
if (!dir)
{
if (!dir) {
return 0;
}
}
unsigned long count = 0;
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) )
{
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
count++;
}
}
closedir(dir);
return count;
}
......