Ignore:
Timestamp:
Jan 5, 2002, 8:11:10 PM (24 years ago)
Author:
umoeller
Message:

Tons of updates for turbo folders and replacement icons.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dosh.c

    r126 r127  
    16401640 */
    16411641
     1642/*
    16421643APIRET doshOpenExisting(PCSZ pcszFilename,   // in: file name
    16431644                        ULONG ulOpenFlags,          // in: open flags
     
    16541655                    NULL));     // EAs
    16551656}
    1656 
    1657 /*
    1658  *@@ doshWriteAt:
    1659  *      writes cb bytes (pointed to by pbData) to the
    1660  *      position specified by ulMethod and lOffset into
    1661  *      the file specified by hf.
    1662  *
    1663  *      If ulMethod is FILE_BEGIN, lOffset specifies the
    1664  *      offset from the beginning of the file. With
    1665  *      FILE_CURRENT, lOffset is considered from the
    1666  *      current file pointer, and with FILE_END, it is
    1667  *      considered from the end of the file.
    1668  *
    1669  *@@added V0.9.13 (2001-06-14) [umoeller]
    1670  */
    1671 
    1672 APIRET doshWriteAt(HFILE hf,        // in: OS/2 file handle
    1673                    LONG lOffset,    // in: offset to write at (depends on ulMethod)
    1674                    ULONG ulMethod,  // in: one of FILE_BEGIN, FILE_CURRENT, FILE_END
    1675                    ULONG cb,        // in: bytes to write
    1676                    PBYTE pbData)    // in: ptr to bytes to write (must be cb bytes)
    1677 {
    1678     APIRET arc;
    1679     ULONG ulDummy;
    1680     if (!(arc = DosSetFilePtr(hf,
    1681                               lOffset,
    1682                               ulMethod,
    1683                               &ulDummy)))
    1684         arc = DosWrite(hf,
    1685                        pbData,
    1686                        cb,
    1687                        &ulDummy);
    1688 
    1689     return (arc);
    1690 }
    1691 
    1692 /*
    1693  *@@ doshReadAt:
    1694  *      reads cb bytes from the position specified by
    1695  *      ulMethod and lOffset into the buffer pointed to
    1696  *      by pbData, which should be cb bytes in size.
    1697  *
    1698  *      Use lOffset and ulMethod as with doshWriteAt.
    1699  *
    1700  *@@added V0.9.13 (2001-06-14) [umoeller]
    1701  */
    1702 
    1703 APIRET doshReadAt(HFILE hf,        // in: OS/2 file handle
    1704                   LONG lOffset,    // in: offset to write at (depends on ulMethod)
    1705                   ULONG ulMethod,  // in: one of FILE_BEGIN, FILE_CURRENT, FILE_END
    1706                   PULONG pcb,      // in: bytes to read, out: bytes read
    1707                   PBYTE pbData)    // out: read buffer (must be cb bytes)
    1708 {
    1709     APIRET arc;
    1710     ULONG cb = *pcb;
    1711     ULONG ulDummy;
    1712 
    1713     *pcb = 0;
    1714 
    1715     if (!(arc = DosSetFilePtr(hf,
    1716                               lOffset,
    1717                               ulMethod,
    1718                               &ulDummy)))
    1719     {
    1720         if (!(arc = DosRead(hf,
    1721                             pbData,
    1722                             cb,
    1723                             &ulDummy)))
    1724             *pcb = ulDummy;     // bytes read
    1725     }
    1726 
    1727     return (arc);
    1728 }
     1657*/
    17291658
    17301659/*
     
    17411670 +      +-------------------------+------+------------+-----------+
    17421671 +      |  XOPEN_READ_EXISTING    | read | opens      | fails     |
     1672 +      |                         |      | fptr = 0   |           |
     1673 +      +-------------------------+------+------------+-----------+
     1674 +      |  XOPEN_READWRITE_EXISTING r/w  | opens      | fails     |
    17431675 +      |                         |      | fptr = 0   |           |
    17441676 +      +-------------------------+------+------------+-----------+
     
    18021734            fsOpenMode |=   OPEN_SHARE_DENYWRITE
    18031735                          | OPEN_ACCESS_READONLY;
    1804             // _Pmpf((__FUNCTION__ ": opening XOPEN_READ_EXISTING"));
    18051736
    18061737            // run this first, because if the file doesn't
     
    18081739            // which isn't that meaningful
    18091740            // V0.9.16 (2001-12-08) [umoeller]
     1741            arc = doshQueryPathSize(pcszFilename,
     1742                                    pcbFile);
     1743        break;
     1744
     1745        case XOPEN_READWRITE_EXISTING:
     1746            fsOpenFlags =   OPEN_ACTION_FAIL_IF_NEW
     1747                          | OPEN_ACTION_OPEN_IF_EXISTS;
     1748            fsOpenMode |=   OPEN_SHARE_DENYWRITE
     1749                          | OPEN_ACCESS_READWRITE;
     1750
    18101751            arc = doshQueryPathSize(pcszFilename,
    18111752                                    pcbFile);
     
    19281869
    19291870/*
     1871 *@@ doshReadAt:
     1872 *      reads cb bytes from the position specified by
     1873 *      lOffset into the buffer pointed to by pbData,
     1874 *      which should be cb bytes in size.
     1875 *
     1876 *      Note that lOffset is always considered to
     1877 *      be from the beginning of the file (FILE_BEGIN
     1878 *      method).
     1879 *
     1880 *@@added V0.9.13 (2001-06-14) [umoeller]
     1881 *@@changed V0.9.16 (2001-12-18) [umoeller]: now with XFILE, and always using FILE_BEGIN
     1882 */
     1883
     1884APIRET doshReadAt(PXFILE pFile,
     1885                  ULONG ulOffset,    // in: offset to read from (from beginning of file)
     1886                  PULONG pcb,      // in: bytes to read, out: bytes read
     1887                  PBYTE pbData)    // out: read buffer (must be cb bytes)
     1888{
     1889    APIRET arc;
     1890    ULONG cb = *pcb;
     1891    ULONG ulDummy;
     1892
     1893    if (!(arc = doshLockFile(pFile)))   // this checks for pFile
     1894    {
     1895        *pcb = 0;
     1896
     1897        if (!(arc = DosSetFilePtr(pFile->hf,
     1898                                  (LONG)ulOffset,
     1899                                  FILE_BEGIN,
     1900                                  &ulDummy)))
     1901        {
     1902            if (!(arc = DosRead(pFile->hf,
     1903                                pbData,
     1904                                cb,
     1905                                &ulDummy)))
     1906                *pcb = ulDummy;     // bytes read
     1907        }
     1908
     1909        doshUnlockFile(pFile);
     1910    }
     1911
     1912    return (arc);
     1913}
     1914
     1915/*
    19301916 *@@ doshWrite:
    19311917 *      writes the specified data to the file.
     
    19371923 *      writing.
    19381924 *
     1925 *      Note that this expects that the file
     1926 *      pointer is at the end of the file, or
     1927 *      you will get garbage.
     1928 *
    19391929 *@@added V0.9.16 (2001-10-19) [umoeller]
    19401930 *@@changed V0.9.16 (2001-12-02) [umoeller]: added XOPEN_BINARY \r\n support
     
    19431933
    19441934APIRET doshWrite(PXFILE pFile,
    1945                  PCSZ pcsz,
    1946                  ULONG cb)
     1935                 ULONG cb,
     1936                 PCSZ pbData)
    19471937{
    19481938    APIRET arc = NO_ERROR;
    1949     if ((!pFile) || (!pcsz))
     1939    if ((!pFile) || (!pbData))
    19501940        arc = ERROR_INVALID_PARAMETER;
    19511941    else
    19521942    {
    19531943        if (!cb)
    1954             cb = strlen(pcsz);
     1944            cb = strlen(pbData);
    19551945
    19561946        if (!cb)
     
    19671957                // count all \n first
    19681958                ULONG cNewLines = 0;
    1969                 PCSZ pSource = pcsz;
     1959                PCSZ pSource = pbData;
    19701960                ULONG ul;
    19711961                for (ul = 0;
     
    19871977                    {
    19881978                        PSZ pTarget = pszNew;
    1989                         pSource = pcsz;
     1979                        pSource = pbData;
    19901980                        for (ul = 0;
    19911981                             ul < cb;
     
    20102000                                         (pszNew)
    20112001                                                ? pszNew
    2012                                                 : (PSZ)pcsz,
     2002                                                : (PSZ)pbData,
    20132003                                         cb,
    20142004                                         &cbWritten)))
     
    20212011                free(pszNew);
    20222012        }
     2013    }
     2014
     2015    return (arc);
     2016}
     2017
     2018/*
     2019 *@@ doshWriteAt:
     2020 *      writes cb bytes (pointed to by pbData) to the
     2021 *      specified file at the position lOffset (from
     2022 *      the beginning of the file).
     2023 *
     2024 *@@added V0.9.13 (2001-06-14) [umoeller]
     2025 */
     2026
     2027APIRET doshWriteAt(PXFILE pFile,
     2028                   ULONG ulOffset,    // in: offset to write at
     2029                   ULONG cb,        // in: bytes to write
     2030                   PCSZ pbData)     // in: ptr to bytes to write (must be cb bytes)
     2031{
     2032    APIRET arc;
     2033    if (!(arc = doshLockFile(pFile)))   // this checks for pFile
     2034    {
     2035        ULONG cbWritten;
     2036        if (!(arc = DosSetFilePtr(pFile->hf,
     2037                                  (LONG)ulOffset,
     2038                                  FILE_BEGIN,
     2039                                  &cbWritten)))
     2040        {
     2041            if (!(arc = DosWrite(pFile->hf,
     2042                                 (PSZ)pbData,
     2043                                 cb,
     2044                                 &cbWritten)))
     2045            {
     2046                if (ulOffset + cbWritten > pFile->cbCurrent)
     2047                    pFile->cbCurrent = ulOffset + cbWritten;
     2048            }
     2049        }
     2050
     2051        doshUnlockFile(pFile);
    20232052    }
    20242053
     
    20592088        {
    20602089            if (!(arc = doshWrite(pFile,
    2061                                   szTemp,
    2062                                   ulLength)))
     2090                                  ulLength,
     2091                                  szTemp)))
    20632092            {
    20642093                va_list arg_ptr;
     
    20732102
    20742103                arc = doshWrite(pFile,
    2075                                 (PCSZ)szTemp,
    2076                                 ulLength);
     2104                                ulLength,
     2105                                szTemp);
    20772106            }
    20782107        }
Note: See TracChangeset for help on using the changeset viewer.