Created
November 24, 2017 10:41
-
-
Save iosdevzone/bfc113ad0323832d32a336f8b4a2bc0e to your computer and use it in GitHub Desktop.
A quick and dirty POC (Plain Ol' C) program to test file creation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| int main(int argc, const char* argv[]) | |
| { | |
| char name[1024]; | |
| char buffer[150]; | |
| for (int i = 0; i < 100000; ++i) { | |
| arc4random_buf(buffer, sizeof(buffer)); | |
| snprintf(name, sizeof(name), "/Users/idz/JezenTest/%d.bin", i); | |
| int fd = open(name, O_WRONLY|O_CREAT, 0777); | |
| if(fd < 0) | |
| { | |
| perror("open"); | |
| exit(EXIT_FAILURE); | |
| } | |
| int n = write(fd, buffer, sizeof(buffer)); | |
| if (n != sizeof(buffer)) | |
| { | |
| perror("write"); | |
| exit(EXIT_FAILURE); | |
| } | |
| close(fd); | |
| } | |
| return EXIT_SUCCESS; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment