blob: 368b0f4d65fee8176285b0a06e6fc9e7bb93a8ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
import os
def os_read_exactly(file_descriptor, nbytes):
"""
Replacement for os.read that blocks until it reads exactly nbytes.
"""
s = ''
while nbytes > 0:
sbuf = os.read(file_descriptor, nbytes)
if not(sbuf):
return ''
nbytes -= len(sbuf)
s = s + sbuf
return s
|