mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-11-18 19:09:31 +00:00
1 line
5.7 KiB
C
1 line
5.7 KiB
C
|
/*
* Copyright (c) Kopriha Software, 1990-1991
* All Rights Reserved
*
* Open.CC
*
* Description:
* This module exists to abstract the data of the file I/O
* primitives of GS/OS.
*
*
* History:Oct 13, 1990 Dave Created this file
*
* Feb 25, 1991 Dave Added I/O buffering
*
* May 26, 1991 Dave Added set EOF
*
* Jun 07, 1991 Dave Broke the single source into lots
* of small sources so we can build
* a library to use...
*
*/
/*
* define DEBUG_CODE
* - add # to define to create the local
* debug code (IE:module)
*/
#ifndef _KS_FILEIO_
#include "ks.fileio.h"
#endif
#pragma noroot
/* ****************************************************************** *
* ks_file_open - open a file for reading/writing. *
* *
* History: Oct 12, 1990 Dave Created this routine *
* ****************************************************************** */
#undef ROUTINE_NAME
#define ROUTINE_NAME "ks_file_open"
KS_E_ERROR ks_file_open(GSString255Ptr GSPathPtr,
Word access,
Word file_fork,
Word buffer_flag,
KS_FILE_HDL file_hdl)
{
/* ************************************************************** *
* Local declarations: *
* ************************************************************** */
KS_E_ERROR error; /* Holds error codes for subroutines */
KS_FILE_PTR file_ptr; /* Pointer to the new KS_FILE struct */
Handle file_handle; /* Handle to the file pointer */
Word file_ref; /* File reference number (for errors) */
ROUTINE_ENTER();
/* ************************************************************** *
* Open the file for our caller. *
* ************************************************************** */
KSf_pkts.open.pCount = 15;
KSf_pkts.open.pathname = GSPathPtr;
KSf_pkts.open.requestAccess = access;
KSf_pkts.open.resourceNumber = file_fork;
KSf_pkts.open.optionList = (ResultBuf255Ptr)
&(KSf_pkts2.optionList[0]);
KSf_pkts2.optionList[0] = sizeof(KSf_pkts2.optionList)
- sizeof(Word);
OpenGS(&KSf_pkts.open);
if ((error = GET_ERROR()) != KS_E_SUCCESS)
{
goto EXIT_NOW;
};
file_ref = KSf_pkts.open.refNum;
/* ************************************************************** *
* The file is open, now lets setup the KS_FILE structure. *
* *
* Allocate a KS_FILE structure, fill it in and return the *
* file pointer (actually, store it through the handle). *
* ************************************************************** */
KS_MEMORY_ALLOCATE(attrNoSpec + attrLocked,
sizeof(KS_FILE),
BUFFER_USERID,
file_handle,
error);
if (error != KS_E_SUCCESS)
{
goto CLOSE_EXIT;
};
file_ptr = (KS_FILE_PTR) *file_handle;
file_ptr->file_handle = file_handle;
file_ptr->access = access;
file_ptr->refNum = KSf_pkts.open.refNum;
file_ptr->eof = KSf_pkts.open.eof;
file_ptr->resource_eof = KSf_pkts.open.resourceEOF;
file_ptr->fileType = KSf_pkts.open.fileType;
file_ptr->auxType = KSf_pkts.open.auxType;
file_ptr->end_of_file = FALSE;
file_ptr->end_of_dir = TRUE;
file_ptr->struct_id = KS_FILE_ID;
/* ************************************************************** *
* We have a good KS_FILE structure, lets try to setup a buffer *
* to do I/O to/from if our caller wants one. *
* ***************
|