posix

LoadLibraryW and POSIX path separator

怎甘沉沦 提交于 2020-08-09 05:44:10
问题 The MSDN documentation for LoadLibrary warns not to use normal Unix slash "/": When specifying a path, be sure to use backslashes (\), not forward slashes (/). I couldn't find any problems using either forward slashes or backslashes (or both) when calling this API. I tried the following pathnames: c:/foo/bar/baz.dll /foo/bar/baz.dll c:/foo/bar\\baz.dll /foo/bar\\baz.dll ./bar/baz.dll All combinations worked as expected. Why does the MSDN recommend against using forward slashes as path

LoadLibraryW and POSIX path separator

試著忘記壹切 提交于 2020-08-09 05:43:30
问题 The MSDN documentation for LoadLibrary warns not to use normal Unix slash "/": When specifying a path, be sure to use backslashes (\), not forward slashes (/). I couldn't find any problems using either forward slashes or backslashes (or both) when calling this API. I tried the following pathnames: c:/foo/bar/baz.dll /foo/bar/baz.dll c:/foo/bar\\baz.dll /foo/bar\\baz.dll ./bar/baz.dll All combinations worked as expected. Why does the MSDN recommend against using forward slashes as path

POSIX fdopen() function in C

断了今生、忘了曾经 提交于 2020-06-29 04:04:23
问题 When should we use fdopen and how do we use it? My understanding of that is when we can't use fopen to read (read from pipe). I don't really understand the description of fdopen on the man page: The fdopen() function associates a stream with the existing file descriptor, fd . 回答1: You use fdopen() when you have a file descriptor ( int fd; ) of some sort but you need to call functions that require a file stream ( FILE *fp; ) instead. This could be a pipe file descriptor, or a socket file

POSIX fdopen() function in C

丶灬走出姿态 提交于 2020-06-29 04:04:11
问题 When should we use fdopen and how do we use it? My understanding of that is when we can't use fopen to read (read from pipe). I don't really understand the description of fdopen on the man page: The fdopen() function associates a stream with the existing file descriptor, fd . 回答1: You use fdopen() when you have a file descriptor ( int fd; ) of some sort but you need to call functions that require a file stream ( FILE *fp; ) instead. This could be a pipe file descriptor, or a socket file

How to properly replace sprintf_s by sprintf in C++03?

半城伤御伤魂 提交于 2020-06-26 03:48:31
问题 sprintf_s is a Microsoft implementation of the function sprintf where they patched a flaw, adding an argument to take a boundary value where the function is limited to write. An equivalent was introduced in C++11 : snprintf . But here, we are talking of C++03 syntax. Signatures: count_char_written sprintf(char* string_out, const char* output_template, VARIADIC_ARGS); // and count_char_written sprintf_s(char* string_out, size_t buffer_max_size, const char* output_template, VARIADIC_ARGS);

What does it take to be durable on Linux?

风格不统一 提交于 2020-06-25 09:02:09
问题 I'm writing some software to deal with pretty critical data, and need to know what exactly I need to do to achieve durability. Everywhere I look is contradictory information, so I'd appreciate any insight. There are three ways I write to disk. Using O_DIRECT | O_DSYNC, and pread'ing and then pwrite'ing 512 byte - 16 MB blocks. Using O_DIRECT, pread'ing and then pwrite'ing 512 byte blocks, and calling fdatasync as regularly as necessary. Using a memory mapped file, which I call msync(..., MS

UNIX domain datagram socket — server does not receive all records

送分小仙女□ 提交于 2020-06-17 09:40:54
问题 I have a multicore program that uses a UNIX domain datagram socket. Three cores (or more, but 3 in this example) send records with sendto and one core receives records with recvfrom and processes the records sent by multiple clients. Each core is assigned to a separate core (using its affinity mask). The program processes a data series in a loop and at the end of each iteration the cores send data to the socket. The data series is small 64-bit integers. My problem is that I receive records

Using Linux POSIX IPC message queue

十年热恋 提交于 2020-06-16 12:54:02
问题 I have to create single Server Process A and multiple client process(es). All should use Linux POSIX IPC message queue for data passing. Message(s) will flow in both direction. It is also possible that at time multiple client process(es) may have registered to Server Process A. Currently I'm using only one named Message queue which is created and Opened by Server Process A and used/opened (only) by client process(es). This works with two process scenario (i.e One server Process A and one

How to modify a single file inside a very large zip without re-writing the entire zip?

≯℡__Kan透↙ 提交于 2020-06-16 03:35:08
问题 I have large zip files that contain huge files. There are "metadata" text files within the zip archives that need to be modified. However, it is not possible to extract the entire zip and re-compress it. I need to locate the target text file inside the zip, edit it, and possibly append the change to the zip file. The file name of the text file is always the same, so it can be hard-coded. Is this possible? Is there a better way? 回答1: There are two approaches. First, if you're just trying to