os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/file.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/file.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,96 @@
     1.4 +/************************************************************************
     1.5 + *
     1.6 + * file.h - common file I/O definitions
     1.7 + *
     1.8 + * $Id: file.h 290020 2005-09-18 23:58:30Z sebor $
     1.9 + *
    1.10 + ***************************************************************************
    1.11 + *
    1.12 + * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
    1.13 + * Software division. Licensed under the Apache License, Version 2.0 (the
    1.14 + * "License");  you may  not use this file except  in compliance with the
    1.15 + * License.    You    may   obtain   a   copy   of    the   License    at
    1.16 + * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
    1.17 + * applicable law  or agreed to  in writing,  software  distributed under
    1.18 + * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
    1.19 + * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
    1.20 + * for the specific language governing permissions  and limitations under
    1.21 + * the License.
    1.22 + * 
    1.23 + **************************************************************************/
    1.24 +
    1.25 +#ifndef RW_FILE_H_INCLUDED
    1.26 +#define RW_FILE_H_INCLUDED
    1.27 +
    1.28 +
    1.29 +#include <testdefs.h>   // for test config macros
    1.30 +
    1.31 +
    1.32 +#ifndef _MSC_VER
    1.33 +   // POSIX special files:
    1.34 +   // http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap10.html
    1.35 +#  define DEV_CONSOLE   "/dev/console"
    1.36 +#  define DEV_NULL      "/dev/null"
    1.37 +#  define DEV_TTY       "/dev/tty"
    1.38 +#else   // if defined (_MSC_VER)
    1.39 +#  define DEV_CONSOLE   "CON:"
    1.40 +#  define DEV_NULL      "NUL:"
    1.41 +#  define DEV_TTY       "CON:"
    1.42 +#endif   // _MSC_VER
    1.43 +
    1.44 +
    1.45 +#if _RWSTD_PATH_SEP == '/'
    1.46 +#  define SLASH          "/"
    1.47 +#  define SHELL_MV       "mv "
    1.48 +#  define SHELL_RM_F     "rm -f "
    1.49 +#  define SHELL_RM_RF    "rm -rf "
    1.50 +#else
    1.51 +#  define SLASH          "\\"
    1.52 +#  define SHELL_MV       "move /Y "
    1.53 +#  define SHELL_RM_F     "del /F "
    1.54 +#  define SHELL_RM_RF    "rmdir /Q /S "
    1.55 +#endif
    1.56 +
    1.57 +
    1.58 +// writes chars using symbolic names from the Portable Character Set (PCS)
    1.59 +// or using the <U00XX> notations for narrow characters outside that set
    1.60 +// if teh second argument is 0, writes out the CHARMAP section of the locale
    1.61 +// definition file for the Portable Character Set (in POSIX-compliant format) 
    1.62 +_TEST_EXPORT void
    1.63 +pcs_write (void*, const char*);
    1.64 +
    1.65 +
    1.66 +// creates a unique temporary file name as if by calling tmpnam()
    1.67 +// but avoiding various platform-specific quirks (such as HP-UX
    1.68 +// failure when _REENTRANT is #defined or GNU glibc warnings)
    1.69 +_TEST_EXPORT
    1.70 +const char* rw_tmpnam (char*);
    1.71 +
    1.72 +// tries to open file named by the first argument and, if successful,
    1.73 +// allocates a block of storage sufficiently large to hold the file's
    1.74 +// entire contents, as determined by the stat() function; it then reads
    1.75 +// the contents of the file into the block of storage, returning a pointer
    1.76 +// to the block; if the second argument is non-0, sets the pointed-to value
    1.77 +// to the number of bytes read
    1.78 +// as a special case, when the first argument is 0 and the second is not,
    1.79 +// the function takes the third argument as a pointer to the buffer that
    1.80 +// it will use to read the contents of files into in subsequent calls,
    1.81 +// provided the buffer is large enough
    1.82 +_TEST_EXPORT void*
    1.83 +rw_fread (const char*,
    1.84 +          _RWSTD_SIZE_T* = 0   /* size in bytes */,
    1.85 +          const char*    = "r" /* stdio open mode */);
    1.86 +
    1.87 +// if the second argument is non-0, writes N bytes starting at that
    1.88 +// location into the file named by the first argument; N is taken
    1.89 +// from the value pointed to by the third argument, if non-0, or
    1.90 +// as the result of calling strlen() on the buffer pointed to by
    1.91 +// the second argument; if the second argument is 0, the function
    1.92 +// removes the named file; returns the number of bytes written
    1.93 +_TEST_EXPORT _RWSTD_SIZE_T
    1.94 +rw_fwrite (const char*,
    1.95 +           const void*,
    1.96 +           _RWSTD_SIZE_T = ~0  /* size in bytes */,
    1.97 +           const char*   = "w" /* stdio open mode */ );
    1.98 +
    1.99 +#endif   // RW_FILE_H_INCLUDED