<commit_before>//
//  SVZForwardingStream.mm
//  SevenZip
//
//  Created by <NAME> on 2015. 11. 26..
//  Copyright © 2015. <NAME>. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SVZForwardingStream.h"

namespace SVZ {

    STDMETHODIMP ForwardingStream::Read(void* data, UInt32 size, UInt32* processedSize) {
        @autoreleasepool {
            NSInteger bytesRead = [_source read:(uint8_t*)data maxLength:size];
            if (processedSize) {
                *processedSize = (UInt32)bytesRead;
            }
        }
        return S_OK;
    }
    
    ForwardingStream::ForwardingStream(NSInputStream* source): _source(source) {
    }
    
    ForwardingStream::~ForwardingStream() {
        _source = nil;
    }
}<commit_msg>Handled possible stream failure + remembered to have to open the stream...<commit_after>//
//  SVZForwardingStream.mm
//  SevenZip
//
//  Created by <NAME> on 2015. 11. 26..
//  Copyright © 2015. <NAME>. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SVZForwardingStream.h"

namespace SVZ {

    STDMETHODIMP ForwardingStream::Read(void* data, UInt32 size, UInt32* processedSize) {
        @autoreleasepool {
            NSInteger bytesRead = [_source read:(uint8_t*)data maxLength:size];
            if (bytesRead < 0) {
                // stream error
                if (processedSize) {
                    *processedSize = 0;
                }
                return E_FAIL;
            }
            
            if (processedSize) {
                *processedSize = (UInt32)bytesRead;
            }
        }

        return S_OK;
    }
    
    ForwardingStream::ForwardingStream(NSInputStream* source): _source(source) {
        @autoreleasepool {
            [_source open];
        }
    }
    
    ForwardingStream::~ForwardingStream() {
        @autoreleasepool {
            [_source close];
        }
        _source = nil;
    }
}
{'fraction_non_alphanumeric': 0.11180447217888716, 'fraction_numerical': 0.02080083203328133, 'mean_word_length': 1.9195751138088013, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4016259', 'n_tokens_mistral': 622, 'n_tokens_neox': 560, 'n_words': 123}