Changeset 48


Ignore:
Timestamp:
Sep 25, 2019, 12:43:50 AM (6 years ago)
Author:
Alex Taylor
Message:

Add Sys2SetSize

Location:
rxutilex/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • rxutilex/trunk/rxutilex.c

    r47 r48  
    11/******************************************************************************
    22 * REXX Utility Functions - Extended (RXUTILEX.DLL)                           *
    3  * (C) 2011, 2017 Alex Taylor.                                                *
     3 * (C) 2011, 2019 Alex Taylor.                                                *
    44 *                                                                            *
    55 * LICENSE:                                                                   *
     
    147147    "Sys2Close",
    148148    "Sys2Seek",
     149    "Sys2SetSize",
    149150    "Sys2BytesRemaining",
    150151    "Sys2Read",
     
    196197RexxFunctionHandler Sys2Write;
    197198RexxFunctionHandler Sys2SyncBuffer;
     199RexxFunctionHandler Sys2SetSize;
    198200
    199201
     
    202204
    203205#ifndef LEGACY_C_LOCALE
    204 int GetLocaleString( PSZ *ppszItem, LocaleItem item );
     206    int GetLocaleString( PSZ *ppszItem, LocaleItem item );
    205207    void GroupNumber( PSZ buf, ULONGLONG val, PSZ sep );
    206208#endif
     
    22082210    sprintf( achActual, "%lld", llActual );
    22092211    SaveResultString( prsResult, achActual, strlen(achActual) );        // 2016-02-20 SHL
     2212
     2213    return ( 0 );
     2214}
     2215
     2216
     2217/* ------------------------------------------------------------------------- *
     2218 * Sys2SetSize                                                               *
     2219 *                                                                           *
     2220 * Wrapper to DosSetFileSizeL: set the size of a file opened with Sys2Open.  *
     2221 *                                                                           *
     2222 * REXX ARGUMENTS:                                                           *
     2223 *   1. File handle (returned by Sys2Open)                        (REQUIRED) *
     2224 *   2. The new size of the file                                  (REQUIRED) *
     2225 *                                                                           *
     2226 * REXX RETURN VALUE:                                                        *
     2227 *   1 on success, or 0 if an error occurred.                                *
     2228 * ------------------------------------------------------------------------- */
     2229ULONG APIENTRY Sys2SetSize( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult )
     2230{
     2231    HFILE    hf;
     2232    LONGLONG llSize;
     2233    APIRET   rc;
     2234
     2235    // Reset the error indicator
     2236    WriteErrorCode( 0, NULL );
     2237
     2238    // Make sure we have two valid arguments
     2239    if ( argc < 2 || ( !RXVALIDSTRING(argv[0]) ) || ( !RXVALIDSTRING(argv[1]) ))
     2240        return ( 40 );
     2241
     2242    // First argument: file handle
     2243    if (( sscanf( argv[0].strptr, "%8X", &hf )) != 1 ) return ( 40 );
     2244
     2245    // Second argument: requested size
     2246    if (( sscanf( argv[1].strptr, "%lld", &llSize )) != 1 ) return ( 40 );
     2247
     2248    rc = DosSetFileSizeL( hf, llSize );
     2249    if ( rc != NO_ERROR ) {
     2250        WriteErrorCode( rc, "DosSetFileSizeL");
     2251        SaveResultString( prsResult, PSZ_ZERO, 1 );
     2252    }
     2253    else {
     2254        SaveResultString( prsResult, PSZ_ONE, 1 );
     2255    }
    22102256
    22112257    return ( 0 );
  • rxutilex/trunk/rxutilex.def

    r47 r48  
    11LIBRARY     RXUTILEX INITINSTANCE TERMINSTANCE
    22DATA        MULTIPLE NONSHARED
    3 DESCRIPTION '@#Alex Taylor:0.1.7#@##1## 22 Sep 2019 23:22:58     reinforce::::::@@Extended REXX Utility Functions'
     3DESCRIPTION '@#Alex Taylor:0.1.7#@##1## 24 Sep 2019 18:41:10     reinforce::::::@@Extended REXX Utility Functions'
    44
    55EXPORTS     Sys2LoadFuncs
     
    3333Sys2QuerySysValue
    3434Sys2Exec
    35 
     35Sys2SetSize
  • rxutilex/trunk/rxutilex.txt

    r47 r48  
    172172                                                                         
    173173Executes an external program and returns the process ID or termination
    174 code.  Wrapper to DosExecPgm.  If the called program requires user input,
    175 it must be the same type (PM or text mode) as the program which calls this
    176 function.
     174code.  Wrapper to DosExecPgm().  Note that text mode programs requiring
     175user input cannot be started from a PM program using this function;
     176they can only be started from another text mode program (in which case
     177it is inadvisable to start them using any mode other than EXEC_SYNC).
    177178                                                                         
    178179REXX ARGUMENTS:                                                         
     
    687688
    688689-------------------------------------------------------------------------
     690Sys2SetSize
     691
     692Set the size of a file to a specific number of bytes; files larger than
     6932GB are supported (this function is a wrapper to DosSetFileSizeL).
     694
     695REXX ARGUMENTS:
     696  1. File handle (returned by Sys2Open).  (REQUIRED)
     697  2. The new file size, in bytes.         (REQUIRED)
     698
     699REXX RETURN VALUE:
     700  1 on success, or 0 if an error occurred.
     701
     702
     703-------------------------------------------------------------------------
    689704Sys2SyncBuffer
    690705
     
    700715REXX RETURN VALUE:  1 on success, 0 on failure
    701716
     717
    702718-------------------------------------------------------------------------
    703719Sys2Version
  • rxutilex/trunk/testlib.cmd

    r47 r48  
    5858say 'Started program with PID =' pid
    5959
     60/*
     61hf = Sys2Open('test1')
     62CALL Sys2SetSize hf, 100
     63CALL Sys2Close hf
     64*/
     65
    6066call Sys2DropFuncs
    6167return 0
Note: See TracChangeset for help on using the changeset viewer.