Skip to content

Instantly share code, notes, and snippets.

@iosdevzone
Created November 24, 2017 10:41
Show Gist options
  • Select an option

  • Save iosdevzone/bfc113ad0323832d32a336f8b4a2bc0e to your computer and use it in GitHub Desktop.

Select an option

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.
#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