17,667 questions
-3
votes
1
answer
153
views
ofstream creates a file, but doesn't open [closed]
I'm trying to open a file as output so that I can write converted model data to my file. The problem currently is, even though the path does exist, and the file is created, it isn't actually open. I'...
Advice
2
votes
6
replies
128
views
EOF during reading from a stream
Why does the following code throw an EOF exception during reading from the stream?
The stream state is goodbit before reading. All works as expected if I do not enable exception throwing.
https://...
2
votes
2
answers
119
views
How do I operate on continuous piped output from a bash command?
I'm trying to write a small bash script that will take values from my mouse's horizontal scroll wheel to change my system's volume.
Using this guide, I've come up with the following command to ...
Advice
1
vote
21
replies
281
views
How to read a specific text file format in C
I just wanted to ask if it's possible to read to a specific file format, say if I wanted to read from a file that has a format of something "info.uc" or "main.uc", how would I go ...
3
votes
3
answers
237
views
Performance issues with reading lines from *standard-input*
I need to process 100 Gigabytes of logs in a weird format, then do some analysis on the results.
Initial parts of parsing and CLI done, tried on some test data with 1 GB and it took around a minute. I ...
1
vote
1
answer
78
views
What is the best way to detect busy CPU cores for blk-mq request steering in Linux kernel?
I am trying to implement request steering in Linux kernel’s blk-mq layer to distribute I/O requests across CPU cores based on load. My goal is to redirect requests from busy cores to less busy ones to ...
1
vote
1
answer
139
views
Unable to successfully initiate scanning using exec(), shell_exec(), or system()
I've been trying for a few weeks now to fire a batch file that runs the command to scan a document from a scanner attached to the same machine.
I'm working on a web app that (using PHP) is meant to ...
0
votes
2
answers
66
views
Is there a way to set Tabulation width in Ada?
I'm trying to get the hang of the Ada.Text_IO package, and it has many differences with IO of C.
One of them differences is how Get treats control characters and Horizontal or Character Tabulation ...
0
votes
0
answers
40
views
blocking display when called in function called in a display [duplicate]
I run the following code compiled with gfortran
program blocking
implicit none
print *, disp_len("haha")
contains
function disp_len(x)
character(*) :: x
integer :: ...
1
vote
1
answer
103
views
winsock: Can an OVERLAPPED to WSARecv be freed immediately after calling CancelIoEx vs after waiting for completion?
So I am working with a windows IO Completion Port to implement some sort of IO event loop that keeps track of IO operations in a client/server model.
I am heap allocating data for each IO operation, ...
5
votes
2
answers
220
views
How to stop a thread blocked on std::getline()? [duplicate]
In my application, I have a thread which just runs std::getline() constantly to get user input, to then send it to a server via a socket. I've made a signal handler to close the program properly when ...
5
votes
2
answers
264
views
What happens if stdout buffer size is smaller than the string being printed in C?
Hello, I’m experimenting with stdout buffering in C and trying to understand what happens when the buffer is smaller than the string being written.
For example:
#include <stdio.h>
#include <...
3
votes
0
answers
146
views
How to immediately stop `io.Copy(os.Stdin, stream)` when stream is closed in Go?
I’m trying to forward input from os.Stdin to a network stream in Go like this:
go func() {
for {
if _, err := io.Copy(stream, os.Stdin); err != nil {
log.Error(err)
...
1
vote
1
answer
81
views
How to detect pipe close when reading text by line in Python
I have been having a lot of trouble reading text a line at a time from a pipe in Python and determining when the socket has been closed on the writing end. I have had the problem when communicating ...
2
votes
2
answers
150
views
16-bit x86 Assembly Kernel getting stuck when calling input function
Well, I'm writing my own OS just for fun, and I thought it would have been cool to add a bytecode "language" interpreted by the kernel itself. I took inspiration mainly from Java, which is ...
3
votes
0
answers
76
views
How Do I Open A File in a Subclass of BufferedIOBase in Python
I want to create my own reader class that is derived from BufferedIOBase. I'd like to have multiple 'open' class methods with differing parameters to create class instances, like this:
from ...
2
votes
2
answers
101
views
Does setvbuf(_IONBF) disable pipe blocking?
An MRE will be tricky here because this relies on (a very simple) secondary terminal executable, but I'll try my best:
Windows 11, WoW64 (32-bit compatibility) executable mode
c99
An MSVC-like (but ...
2
votes
1
answer
84
views
How can I set my iOS AVAudioSession to return input buffers of <0.1 s?
I'm trying to get short audio samples into my iOS app (in Kotlin Multiplatform). Here's my relatively simple setup (sampleRateInHz is defined elsewhere):
val bufferSize: AVAudioFrameCount = 512u
val ...
0
votes
1
answer
83
views
Printing variable in function in external module results in a different output than printing the variable from main
I am trying to make a sort of input() function for a project I've been working on.
The function simply reads from stdin and returns the string.
Here's what I came up with:
const std = @import("...
0
votes
0
answers
92
views
Generating and downloading a binary file in iOS Safari
My web app generates binary files (byte by byte, using Uint8Array) and I want to let users save these files to their device.
I use URL.createObjectURL( Blob ), see https://jsfiddle.net/u9trmg1p
var a =...
0
votes
1
answer
58
views
Python save TemporaryFile read as "w+b" to compressed tarfile
I am given a SpooledTemporaryFile through FastAPI's UploadFile. My goal is to write it to disk so I can extract it and process its contents later. This seems simple, but I am having problems saving ...
0
votes
0
answers
76
views
Read/write on device file with timeout
I'm currently writing a printer driver in Java 1.6. I need to be able to read/write to the device file (/dev/usb/lp0) with a timeout. I'm using a wrapper around a RandomAccessFile, then use a channel ...
1
vote
0
answers
82
views
Byte Shifting Error White Reading Safetensor File in C
I'm trying to read safetensors file in C. As a read on Huggingface's documentation, I'm taking first 8 byte of file for header size;
...
uint64_t header_size = 0;
int read_header_size = fread(&...
5
votes
3
answers
165
views
How do I print code point names like "NO-BREAK SPACE"?
I have some software that supports UTF-8 config files.
It doesn't have extensive Unicode support, just parsing files.
If there is a code point that is disallowed by the format, I would like to convert ...
0
votes
1
answer
46
views
Files reading and JSON parsing causes UI freezes in workmanager. How to fix?
I need to read from storage and parse > 20 JSON files (around 5-12 MB each) at the same time. I use workmanager for this because it runs in a separate Isolate, but this slows down the UI a lot and ...
0
votes
0
answers
101
views
Write the output of a large iterator to a file
I'm looking to write an iterator Item = u8 to a file. The iterator has a large len so collecting the iterator and then writing the resulting vector isn't very efficient.
I'm thinking of collecting ...
5
votes
3
answers
250
views
Fastest read and sum of integers in C
Basically, I am trying to read a file that contains first a number n of integers, then n integers in range [-10^5, 10^5]. All integers are separated by '\n'. I need to then sum all these integers, ...
3
votes
1
answer
166
views
is there a 64 bit version of _read() or read()?
_read() and read() 3rd argument (_MaxCharCount) is unsigned int, which limits the read to 2GB, is there a version that uses a 64 bit third argument? because there is _lseeki64 so doesnt make sense why ...
2
votes
1
answer
131
views
8259A PIC programming issue?
I want to write my own minimal operating system, and started off with a keyboard driver based on the tutorial of Frank Rosner (https://dev.to/frosnerd/writing-my-own-keyboard-driver-16kh).
Since this ...
1
vote
2
answers
95
views
What is the difference between an MPI nonblocking collective write, iwrite_all vs a "nonblocking" noncollective iwrite combined with a file sync?
I'm setting up IO for a largescale CFD code using the MPI library and the file IO is starting to eat into computation time as my problems scale.
As far as I can find the "done" thing in the ...
3
votes
0
answers
217
views
Numpy IO seems to have an 2GB overhead in StorNex (cvfs) File System
TL;DR:
Initally I thought the numpy load functions doubles memory usage at peak
after some additional tests it seems like the underlying file system (StorNex [cfvs]) leads to a size-independent 2GB ...
3
votes
1
answer
117
views
Console.writer().println() vs Console.format() vs System.out.println()
Console.writer().println() is displaying "Enter 3 words" after console.readLine().
Can anyone explain why?
class Class3{
public static void main(String... args){
Console console =...
0
votes
0
answers
44
views
Why does the first command of my WDL task output its results to the input folder?
I have a WDL workflow that I use miniwdl to run.
The second task of my workflow outputs its first command's results to the input folder by default. I was able to work around this by including '-o .' ...
0
votes
1
answer
71
views
Reading Incorrect Data with C# (Custom PAK File)
I am trying to write my own game engine. I packaged the files such as assets of the games so that the engine can read them faster and easier. However, I encountered a problem. I could not find the ...
0
votes
0
answers
48
views
Why is data written to the file even though the buffer is not full when the program finishes? [duplicate]
I expected that without calling fclose(), and with the buffer not being full, nothing would be written to the file. But when the program finishes, the data still appears in the file.
Or the C runtime ...
2
votes
1
answer
149
views
What's the differences between io.TeeReader and io.MultiWriter?
I want to build an llm app and add a middleware to monitor token usage. The result I get from the llm provider is a sse stream. I googled and get two similar results, io.TeeReader and io.MultiWriter. ...
0
votes
1
answer
53
views
Why is stdout PIPE readline() not waiting for a newline character? [closed]
Why is print(line) in read_stdout printing every character instead of the entire line? I am expecting it to add to the queue once the newline character is reached, but it's just putting every ...
4
votes
2
answers
138
views
Why does read() in C read input in chunks when there's no user-level buffering?
I'm learning how the POSIX read() function works in C. I understand that read() is considered unbuffered, meaning it doesn't manage any internal buffer like fread() does. But I'm confused by the ...
0
votes
1
answer
77
views
Does DMA play a role in process loading (from disk to memory)?
I’m trying to understand how operating systems load a program into memory from a hardware perspective.
I know that DMA (Direct Memory Access) is used for I/O operations, allowing data transfer between ...
-1
votes
1
answer
117
views
Why does the C# compiler suggest using await for File.OpenRead() which does not return a task? [duplicate]
await using (var streamReader = File.OpenRead(filePath))
using (var reader = new StreamReader(streamReader))
{
while ((line = await reader.ReadLineAsync()) != null)
{
// my logic
}
}
...
0
votes
0
answers
48
views
How to write a string containing binary representation of data to file? [duplicate]
I am trying to write a binary string as binary data to file but my function seems to be having a problem with the int conversion. I am reading a text file and manipulating it which gives me a string ...
2
votes
1
answer
101
views
Deleting final line in a text file in C++
I have a program where a user can write (append) to a chosen text file for storing information. Each line should be two numbers, and a date string (YYYY-MM-DD). There a multiple different text files ...
0
votes
1
answer
133
views
Most efficient way to handle I/O for large files [closed]
I am developing a secure P2P file transfer tool in C which is intended to be used for sending arbitrary-size files from between two machines running the program.
I have been trying to figure out what ...
0
votes
1
answer
65
views
Adding Password to Zip file with BytesIO
I am working on a project in which I need to zip a Word document and then upload the file to a Blob Storage in Azure with a password on the zip file. At this point in time I have managed to get the ...
0
votes
2
answers
61
views
Reading a json file from ECS location and transforming it into list of Object?
I am currently reading a json file from s3 location using the below code and then printing the data.
Json File
[
{
"name": "A",
"lastName" : "B"
},
{
...
0
votes
0
answers
48
views
Matching service registry IDs to device registry ID
I am developing an utility which needs to match tapped CGEvents to the USB device that originated them (a touchscreen, specifically).
I got to the point where I can get the Service Registry ID from ...
2
votes
2
answers
83
views
Why is my file deleting itself when I open it?
I’m currently learning BASIC (I use FreeBASIC) and I’m trying to open files. However, instead of opening files, my program deletes them. This is my code:
Dim f as Integer
f = FreeFile
Open "...
4
votes
3
answers
148
views
How do I assign a fstream to an fstream* in C++?
I'm writing a function in C++ that has to return more than one value, and I know that I can't.
So I thought to pass the function two pointers to the files I want to open.
This is the code and then I'...
3
votes
3
answers
180
views
Can non-buffered write return 0?
According to the documentation, write returns either the number of bytes written or -1 in case of an error. It's not clear whether the number of bytes written can be 0 when nbyte is positive. The ...
1
vote
0
answers
55
views
Go writing log file weirdly stuck in netpoll
Researching strange issue with weird delays in the app took me to the line where logging is called. At that line data received from communication channel are simply dumped to the log on trace level (...