@@ -156,7 +156,7 @@ bool __cdecl _sync_fsb_winrt(_In_ Concurrency::streams::details::_file_info *inf
156
156
{
157
157
_ASSERTE (info != nullptr );
158
158
159
- _file_info_impl *fInfo = ( _file_info_impl *) info;
159
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
160
160
161
161
pplx::extensibility::scoped_recursive_lock_t lck (fInfo ->m_lock );
162
162
@@ -172,7 +172,7 @@ bool __cdecl _sync_fsb_winrt(_In_ Concurrency::streams::details::_file_info *inf
172
172
fInfo ->m_buffill = 0 ;
173
173
return writer->FlushAsync ();
174
174
}).then ([=] (pplx::task<bool > result) {
175
- // Rethrow exception if no callback attatched .
175
+ // Rethrow exception if no callback attached .
176
176
if (callback == nullptr )
177
177
result.wait ();
178
178
else
@@ -206,7 +206,7 @@ bool __cdecl _close_fsb_nolock(_In_ _file_info **info, _In_ Concurrency::streams
206
206
_ASSERTE (info != nullptr );
207
207
_ASSERTE (*info != nullptr );
208
208
209
- _file_info_impl *fInfo = ( _file_info_impl *) *info;
209
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( *info) ;
210
210
211
211
*info = nullptr ;
212
212
@@ -265,25 +265,25 @@ size_t __cdecl _read_file_async(_In_ Concurrency::streams::details::_file_info_i
265
265
266
266
auto reader = ref new Streams::DataReader (fInfo ->m_stream ->GetInputStreamAt (offset));
267
267
268
- pplx::create_task (reader->LoadAsync ((unsigned int )count)).then (
269
- [=] (pplx::task<unsigned int > result)
268
+ pplx::create_task (reader->LoadAsync (static_cast <unsigned int >(count))).then (
269
+ [=](pplx::task<unsigned int > result)
270
+ {
271
+ try
270
272
{
271
- try
272
- {
273
- auto read = result.get ();
274
-
275
- if ( read > 0 )
276
- {
277
- reader->ReadBytes (Platform::ArrayReference<unsigned char >(static_cast <unsigned char *>(ptr), read));
278
- }
273
+ auto read = result.get ();
279
274
280
- callback->on_completed (read);
281
- }
282
- catch (Platform::Exception^ exc)
275
+ if (read > 0 )
283
276
{
284
- callback-> on_error ( std::make_exception_ptr ( utility::details::create_system_error (exc-> HResult ) ));
277
+ reader-> ReadBytes (Platform::ArrayReference< unsigned char >( static_cast < unsigned char *>(ptr), read ));
285
278
}
286
- });
279
+
280
+ callback->on_completed (read);
281
+ }
282
+ catch (Platform::Exception^ exc)
283
+ {
284
+ callback->on_error (std::make_exception_ptr (utility::details::create_system_error (exc->HResult )));
285
+ }
286
+ });
287
287
288
288
return 0 ;
289
289
}
@@ -293,7 +293,7 @@ template<typename Func>
293
293
class _filestream_callback_fill_buffer : public _filestream_callback
294
294
{
295
295
public:
296
- _filestream_callback_fill_buffer (_In_ _file_info *info, Func func) : m_func(func), m_info(info) { }
296
+ _filestream_callback_fill_buffer (_In_ _file_info *info, const Func & func) : m_func(func), m_info(info) { }
297
297
298
298
virtual void on_completed (size_t result)
299
299
{
@@ -307,7 +307,7 @@ class _filestream_callback_fill_buffer : public _filestream_callback
307
307
};
308
308
309
309
template <typename Func>
310
- _filestream_callback_fill_buffer<Func> *create_callback (_In_ _file_info *info, Func func)
310
+ _filestream_callback_fill_buffer<Func> *create_callback (_In_ _file_info *info, const Func & func)
311
311
{
312
312
return new _filestream_callback_fill_buffer<Func>(info, func);
313
313
}
@@ -484,7 +484,7 @@ size_t __cdecl _getn_fsb(_In_ Concurrency::streams::details::_file_info *info, _
484
484
_ASSERTE (info != nullptr );
485
485
_ASSERTE (count > 0 );
486
486
487
- _file_info_impl *fInfo = ( _file_info_impl *) info;
487
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
488
488
489
489
pplx::extensibility::scoped_recursive_lock_t lck (info->m_lock );
490
490
@@ -496,19 +496,19 @@ size_t __cdecl _getn_fsb(_In_ Concurrency::streams::details::_file_info *info, _
496
496
auto sz = count*char_size;
497
497
auto copy = (read < sz) ? read : sz;
498
498
auto bufoff = fInfo ->m_rdpos - fInfo ->m_bufoff ;
499
- memcpy (( void *) ptr, fInfo ->m_buffer +bufoff*char_size, copy);
499
+ memcpy (ptr, fInfo ->m_buffer +bufoff*char_size, copy);
500
500
fInfo ->m_atend = copy < sz;
501
501
callback->on_completed (copy);
502
502
});
503
503
504
- int read = ( int ) _fill_buffer_fsb (fInfo , cb, count, char_size);
504
+ size_t read = _fill_buffer_fsb (fInfo , cb, count, char_size);
505
505
506
506
if ( read > 0 )
507
507
{
508
508
auto sz = count*char_size;
509
- auto copy = (( size_t ) read < sz) ? ( size_t ) read : sz;
509
+ auto copy = (read < sz) ? read : sz;
510
510
auto bufoff = fInfo ->m_rdpos - fInfo ->m_bufoff ;
511
- memcpy (( void *) ptr, fInfo ->m_buffer +bufoff*char_size, copy);
511
+ memcpy (ptr, fInfo ->m_buffer +bufoff*char_size, copy);
512
512
fInfo ->m_atend = copy < sz;
513
513
return copy;
514
514
}
@@ -536,7 +536,7 @@ size_t __cdecl _putn_fsb(_In_ Concurrency::streams::details::_file_info *info, _
536
536
_ASSERTE (info != nullptr );
537
537
_ASSERTE (count > 0 );
538
538
539
- _file_info_impl *fInfo = ( _file_info_impl *) info;
539
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
540
540
541
541
pplx::extensibility::scoped_recursive_lock_t lck (fInfo ->m_lock );
542
542
@@ -622,11 +622,11 @@ size_t __cdecl _seekrdpos_fsb(_In_ Concurrency::streams::details::_file_info *in
622
622
{
623
623
_ASSERTE (info != nullptr );
624
624
625
- _file_info_impl *fInfo = ( _file_info_impl *) info;
625
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
626
626
627
627
pplx::extensibility::scoped_recursive_lock_t lck (info->m_lock );
628
628
629
- if ( fInfo ->m_stream == nullptr ) return ( size_t )- 1 ;;
629
+ if ( fInfo ->m_stream == nullptr ) return static_cast < size_t >(- 1 ) ;;
630
630
631
631
if ( pos < fInfo ->m_bufoff || pos > (fInfo ->m_bufoff +fInfo ->m_buffill ) )
632
632
{
@@ -650,7 +650,7 @@ size_t __cdecl _seekrdpos_fsb(_In_ Concurrency::streams::details::_file_info *in
650
650
_ASYNCRTIMP size_t __cdecl _seekrdtoend_fsb (_In_ Concurrency::streams::details::_file_info *info, int64_t offset, size_t char_size)
651
651
{
652
652
_ASSERTE (info != nullptr );
653
- _file_info_impl *fInfo = ( _file_info_impl *) info;
653
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
654
654
655
655
return _seekrdpos_fsb (info, static_cast <size_t >(fInfo ->m_stream ->Size / char_size + offset), char_size);
656
656
}
@@ -659,7 +659,7 @@ utility::size64_t __cdecl _get_size(_In_ concurrency::streams::details::_file_in
659
659
{
660
660
_ASSERTE (info != nullptr );
661
661
662
- _file_info_impl *fInfo = ( _file_info_impl *) info;
662
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
663
663
664
664
pplx::extensibility::scoped_recursive_lock_t lck (info->m_lock );
665
665
@@ -678,11 +678,11 @@ size_t __cdecl _seekwrpos_fsb(_In_ Concurrency::streams::details::_file_info *in
678
678
{
679
679
_ASSERTE (info != nullptr );
680
680
681
- _file_info_impl *fInfo = ( _file_info_impl *) info;
681
+ _file_info_impl *fInfo = static_cast < _file_info_impl *>( info) ;
682
682
683
683
pplx::extensibility::scoped_recursive_lock_t lck (info->m_lock );
684
684
685
- if ( fInfo ->m_stream == nullptr ) return ( size_t )- 1 ; ;
685
+ if ( fInfo ->m_stream == nullptr ) return static_cast < size_t >(- 1 ) ;
686
686
687
687
fInfo ->m_wrpos = pos;
688
688
@@ -793,14 +793,14 @@ ref class IRandomAccessStream_bridge sealed : public Windows::Storage::Streams::
793
793
794
794
internal:
795
795
796
- IRandomAccessStream_bridge (concurrency::streams::streambuf<uint8_t > buffer) :
796
+ IRandomAccessStream_bridge (const concurrency::streams::streambuf<uint8_t > & buffer) :
797
797
m_buffer (buffer),
798
798
m_remembered_size (0 ),
799
799
m_position (0 )
800
800
{
801
801
}
802
802
803
- IRandomAccessStream_bridge (concurrency::streams::streambuf<uint8_t > buffer,
803
+ IRandomAccessStream_bridge (const concurrency::streams::streambuf<uint8_t > & buffer,
804
804
concurrency::streams::streambuf<uint8_t >::pos_type position) :
805
805
m_buffer (buffer),
806
806
m_remembered_size (0 ),
@@ -1026,17 +1026,17 @@ IRandomAccessStream_bridge::FlushAsync()
1026
1026
1027
1027
}}} // namespaces
1028
1028
1029
- Windows::Storage::Streams::IInputStream^ Concurrency::streams::winrt_stream::create_input_stream(concurrency::streams::streambuf<uint8_t > buffer)
1029
+ Windows::Storage::Streams::IInputStream^ Concurrency::streams::winrt_stream::create_input_stream(const concurrency::streams::streambuf<uint8_t > & buffer)
1030
1030
{
1031
1031
return ref new ::Concurrency::streams::details::IRandomAccessStream_bridge (buffer,0 );
1032
1032
}
1033
1033
1034
- Windows::Storage::Streams::IOutputStream^ Concurrency::streams::winrt_stream::create_output_stream(concurrency::streams::streambuf<uint8_t > buffer)
1034
+ Windows::Storage::Streams::IOutputStream^ Concurrency::streams::winrt_stream::create_output_stream(const concurrency::streams::streambuf<uint8_t > & buffer)
1035
1035
{
1036
1036
return ref new Concurrency::streams::details::IRandomAccessStream_bridge (buffer,0 );
1037
1037
}
1038
1038
1039
- Windows::Storage::Streams::IRandomAccessStream^ Concurrency::streams::winrt_stream::create_random_access_stream(concurrency::streams::streambuf<uint8_t > buffer)
1039
+ Windows::Storage::Streams::IRandomAccessStream^ Concurrency::streams::winrt_stream::create_random_access_stream(const concurrency::streams::streambuf<uint8_t > & buffer)
1040
1040
{
1041
1041
return ref new Concurrency::streams::details::IRandomAccessStream_bridge (buffer);
1042
1042
}
0 commit comments