LCOV - code coverage report
Current view: top level - modules/libjar/zipwriter - StreamFunctions.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 18 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       4             :  */
       5             : 
       6             : #include "nscore.h"
       7             : #include "nsIInputStream.h"
       8             : #include "nsIOutputStream.h"
       9             : 
      10             : /*
      11             :  * Fully reads the required amount of data. Keeps reading until all the
      12             :  * data is retrieved or an error is hit.
      13             :  */
      14           0 : nsresult ZW_ReadData(nsIInputStream *aStream, char *aBuffer, uint32_t aCount)
      15             : {
      16           0 :     while (aCount > 0) {
      17             :         uint32_t read;
      18           0 :         nsresult rv = aStream->Read(aBuffer, aCount, &read);
      19           0 :         NS_ENSURE_SUCCESS(rv, rv);
      20           0 :         aCount -= read;
      21           0 :         aBuffer += read;
      22             :         // If we hit EOF before reading the data we need then throw.
      23           0 :         if (read == 0 && aCount > 0)
      24           0 :             return NS_ERROR_FAILURE;
      25             :     }
      26             : 
      27           0 :     return NS_OK;
      28             : }
      29             : 
      30             : /*
      31             :  * Fully writes the required amount of data. Keeps writing until all the
      32             :  * data is written or an error is hit.
      33             :  */
      34           0 : nsresult ZW_WriteData(nsIOutputStream *aStream, const char *aBuffer,
      35             :                                   uint32_t aCount)
      36             : {
      37           0 :     while (aCount > 0) {
      38             :         uint32_t written;
      39           0 :         nsresult rv = aStream->Write(aBuffer, aCount, &written);
      40           0 :         NS_ENSURE_SUCCESS(rv, rv);
      41           0 :         if (written <= 0)
      42           0 :             return NS_ERROR_FAILURE;
      43           0 :         aCount -= written;
      44           0 :         aBuffer += written;
      45             :     }
      46             : 
      47           0 :     return NS_OK;
      48             : }

Generated by: LCOV version 1.13