os/ossrv/stdcpp/tsrc/Stdcpp_test/stdcxx/include/file.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/************************************************************************
sl@0
     2
 *
sl@0
     3
 * file.h - common file I/O definitions
sl@0
     4
 *
sl@0
     5
 * $Id: file.h 290020 2005-09-18 23:58:30Z sebor $
sl@0
     6
 *
sl@0
     7
 ***************************************************************************
sl@0
     8
 *
sl@0
     9
 * Copyright (c) 1994-2005 Quovadx,  Inc., acting through its  Rogue Wave
sl@0
    10
 * Software division. Licensed under the Apache License, Version 2.0 (the
sl@0
    11
 * "License");  you may  not use this file except  in compliance with the
sl@0
    12
 * License.    You    may   obtain   a   copy   of    the   License    at
sl@0
    13
 * http://www.apache.org/licenses/LICENSE-2.0.    Unless   required    by
sl@0
    14
 * applicable law  or agreed to  in writing,  software  distributed under
sl@0
    15
 * the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR
sl@0
    16
 * CONDITIONS OF  ANY KIND, either  express or implied.  See  the License
sl@0
    17
 * for the specific language governing permissions  and limitations under
sl@0
    18
 * the License.
sl@0
    19
 * 
sl@0
    20
 **************************************************************************/
sl@0
    21
sl@0
    22
#ifndef RW_FILE_H_INCLUDED
sl@0
    23
#define RW_FILE_H_INCLUDED
sl@0
    24
sl@0
    25
sl@0
    26
#include <testdefs.h>   // for test config macros
sl@0
    27
sl@0
    28
sl@0
    29
#ifndef _MSC_VER
sl@0
    30
   // POSIX special files:
sl@0
    31
   // http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap10.html
sl@0
    32
#  define DEV_CONSOLE   "/dev/console"
sl@0
    33
#  define DEV_NULL      "/dev/null"
sl@0
    34
#  define DEV_TTY       "/dev/tty"
sl@0
    35
#else   // if defined (_MSC_VER)
sl@0
    36
#  define DEV_CONSOLE   "CON:"
sl@0
    37
#  define DEV_NULL      "NUL:"
sl@0
    38
#  define DEV_TTY       "CON:"
sl@0
    39
#endif   // _MSC_VER
sl@0
    40
sl@0
    41
sl@0
    42
#if _RWSTD_PATH_SEP == '/'
sl@0
    43
#  define SLASH          "/"
sl@0
    44
#  define SHELL_MV       "mv "
sl@0
    45
#  define SHELL_RM_F     "rm -f "
sl@0
    46
#  define SHELL_RM_RF    "rm -rf "
sl@0
    47
#else
sl@0
    48
#  define SLASH          "\\"
sl@0
    49
#  define SHELL_MV       "move /Y "
sl@0
    50
#  define SHELL_RM_F     "del /F "
sl@0
    51
#  define SHELL_RM_RF    "rmdir /Q /S "
sl@0
    52
#endif
sl@0
    53
sl@0
    54
sl@0
    55
// writes chars using symbolic names from the Portable Character Set (PCS)
sl@0
    56
// or using the <U00XX> notations for narrow characters outside that set
sl@0
    57
// if teh second argument is 0, writes out the CHARMAP section of the locale
sl@0
    58
// definition file for the Portable Character Set (in POSIX-compliant format) 
sl@0
    59
_TEST_EXPORT void
sl@0
    60
pcs_write (void*, const char*);
sl@0
    61
sl@0
    62
sl@0
    63
// creates a unique temporary file name as if by calling tmpnam()
sl@0
    64
// but avoiding various platform-specific quirks (such as HP-UX
sl@0
    65
// failure when _REENTRANT is #defined or GNU glibc warnings)
sl@0
    66
_TEST_EXPORT
sl@0
    67
const char* rw_tmpnam (char*);
sl@0
    68
sl@0
    69
// tries to open file named by the first argument and, if successful,
sl@0
    70
// allocates a block of storage sufficiently large to hold the file's
sl@0
    71
// entire contents, as determined by the stat() function; it then reads
sl@0
    72
// the contents of the file into the block of storage, returning a pointer
sl@0
    73
// to the block; if the second argument is non-0, sets the pointed-to value
sl@0
    74
// to the number of bytes read
sl@0
    75
// as a special case, when the first argument is 0 and the second is not,
sl@0
    76
// the function takes the third argument as a pointer to the buffer that
sl@0
    77
// it will use to read the contents of files into in subsequent calls,
sl@0
    78
// provided the buffer is large enough
sl@0
    79
_TEST_EXPORT void*
sl@0
    80
rw_fread (const char*,
sl@0
    81
          _RWSTD_SIZE_T* = 0   /* size in bytes */,
sl@0
    82
          const char*    = "r" /* stdio open mode */);
sl@0
    83
sl@0
    84
// if the second argument is non-0, writes N bytes starting at that
sl@0
    85
// location into the file named by the first argument; N is taken
sl@0
    86
// from the value pointed to by the third argument, if non-0, or
sl@0
    87
// as the result of calling strlen() on the buffer pointed to by
sl@0
    88
// the second argument; if the second argument is 0, the function
sl@0
    89
// removes the named file; returns the number of bytes written
sl@0
    90
_TEST_EXPORT _RWSTD_SIZE_T
sl@0
    91
rw_fwrite (const char*,
sl@0
    92
           const void*,
sl@0
    93
           _RWSTD_SIZE_T = ~0  /* size in bytes */,
sl@0
    94
           const char*   = "w" /* stdio open mode */ );
sl@0
    95
sl@0
    96
#endif   // RW_FILE_H_INCLUDED