Skip to content

Commit

Permalink
Windows support for dup where files are concerned
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Jul 28, 2024
1 parent 89bfac9 commit a281d72
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
6 changes: 5 additions & 1 deletion fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8476,9 +8476,13 @@ SFUNC size_t fio_fd_find_next(int fd, char token, size_t start_at);

#if FIO_OS_WIN
#define FIO_FOLDER_SEPARATOR '\\'
/** Duplicates the file handle (int)*/
#define fio_file_dup(fd) _dup(fd)
#else
#define FIO_FOLDER_SEPARATOR '/'
#endif
/** Duplicates the file handle (int)*/
#define fio_file_dup(fd) dup(fd)
#endif /* FIO_OS_WIN */

/* *****************************************************************************
File Helper Inline Implementation
Expand Down
12 changes: 12 additions & 0 deletions fio-stl.md
Original file line number Diff line number Diff line change
Expand Up @@ -3151,6 +3151,18 @@ Creates a temporary file, returning its file descriptor.

Returns -1 on error.

#### `fio_file_dup`

```c
#if FIO_OS_WIN
#define fio_file_dup(fd) _dup(fd)
#else
#define fio_file_dup(fd) dup(fd)
#endif
```

Duplicates the file handle (int).

#### `fio_filename_overwrite`

```c
Expand Down
6 changes: 5 additions & 1 deletion fio-stl/004 files.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ SFUNC size_t fio_fd_find_next(int fd, char token, size_t start_at);

#if FIO_OS_WIN
#define FIO_FOLDER_SEPARATOR '\\'
/** Duplicates the file handle (int)*/
#define fio_file_dup(fd) _dup(fd)
#else
#define FIO_FOLDER_SEPARATOR '/'
#endif
/** Duplicates the file handle (int)*/
#define fio_file_dup(fd) dup(fd)
#endif /* FIO_OS_WIN */

/* *****************************************************************************
File Helper Inline Implementation
Expand Down
12 changes: 12 additions & 0 deletions fio-stl/004 files.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ Creates a temporary file, returning its file descriptor.
Returns -1 on error.
#### `fio_file_dup`
```c
#if FIO_OS_WIN
#define fio_file_dup(fd) _dup(fd)
#else
#define fio_file_dup(fd) dup(fd)
#endif
```

Duplicates the file handle (int).

#### `fio_filename_overwrite`

```c
Expand Down

0 comments on commit a281d72

Please sign in to comment.