sl@0: /************************************************************************ sl@0: * sl@0: * file.h - common file I/O definitions sl@0: * sl@0: * $Id: file.h 290020 2005-09-18 23:58:30Z sebor $ sl@0: * sl@0: *************************************************************************** sl@0: * sl@0: * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave sl@0: * Software division. Licensed under the Apache License, Version 2.0 (the sl@0: * "License"); you may not use this file except in compliance with the sl@0: * License. You may obtain a copy of the License at sl@0: * http://www.apache.org/licenses/LICENSE-2.0. Unless required by sl@0: * applicable law or agreed to in writing, software distributed under sl@0: * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR sl@0: * CONDITIONS OF ANY KIND, either express or implied. See the License sl@0: * for the specific language governing permissions and limitations under sl@0: * the License. sl@0: * sl@0: **************************************************************************/ sl@0: sl@0: #ifndef RW_FILE_H_INCLUDED sl@0: #define RW_FILE_H_INCLUDED sl@0: sl@0: sl@0: #include // for test config macros sl@0: sl@0: sl@0: #ifndef _MSC_VER sl@0: // POSIX special files: sl@0: // http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap10.html sl@0: # define DEV_CONSOLE "/dev/console" sl@0: # define DEV_NULL "/dev/null" sl@0: # define DEV_TTY "/dev/tty" sl@0: #else // if defined (_MSC_VER) sl@0: # define DEV_CONSOLE "CON:" sl@0: # define DEV_NULL "NUL:" sl@0: # define DEV_TTY "CON:" sl@0: #endif // _MSC_VER sl@0: sl@0: sl@0: #if _RWSTD_PATH_SEP == '/' sl@0: # define SLASH "/" sl@0: # define SHELL_MV "mv " sl@0: # define SHELL_RM_F "rm -f " sl@0: # define SHELL_RM_RF "rm -rf " sl@0: #else sl@0: # define SLASH "\\" sl@0: # define SHELL_MV "move /Y " sl@0: # define SHELL_RM_F "del /F " sl@0: # define SHELL_RM_RF "rmdir /Q /S " sl@0: #endif sl@0: sl@0: sl@0: // writes chars using symbolic names from the Portable Character Set (PCS) sl@0: // or using the notations for narrow characters outside that set sl@0: // if teh second argument is 0, writes out the CHARMAP section of the locale sl@0: // definition file for the Portable Character Set (in POSIX-compliant format) sl@0: _TEST_EXPORT void sl@0: pcs_write (void*, const char*); sl@0: sl@0: sl@0: // creates a unique temporary file name as if by calling tmpnam() sl@0: // but avoiding various platform-specific quirks (such as HP-UX sl@0: // failure when _REENTRANT is #defined or GNU glibc warnings) sl@0: _TEST_EXPORT sl@0: const char* rw_tmpnam (char*); sl@0: sl@0: // tries to open file named by the first argument and, if successful, sl@0: // allocates a block of storage sufficiently large to hold the file's sl@0: // entire contents, as determined by the stat() function; it then reads sl@0: // the contents of the file into the block of storage, returning a pointer sl@0: // to the block; if the second argument is non-0, sets the pointed-to value sl@0: // to the number of bytes read sl@0: // as a special case, when the first argument is 0 and the second is not, sl@0: // the function takes the third argument as a pointer to the buffer that sl@0: // it will use to read the contents of files into in subsequent calls, sl@0: // provided the buffer is large enough sl@0: _TEST_EXPORT void* sl@0: rw_fread (const char*, sl@0: _RWSTD_SIZE_T* = 0 /* size in bytes */, sl@0: const char* = "r" /* stdio open mode */); sl@0: sl@0: // if the second argument is non-0, writes N bytes starting at that sl@0: // location into the file named by the first argument; N is taken sl@0: // from the value pointed to by the third argument, if non-0, or sl@0: // as the result of calling strlen() on the buffer pointed to by sl@0: // the second argument; if the second argument is 0, the function sl@0: // removes the named file; returns the number of bytes written sl@0: _TEST_EXPORT _RWSTD_SIZE_T sl@0: rw_fwrite (const char*, sl@0: const void*, sl@0: _RWSTD_SIZE_T = ~0 /* size in bytes */, sl@0: const char* = "w" /* stdio open mode */ ); sl@0: sl@0: #endif // RW_FILE_H_INCLUDED