Skip to content

Instantly share code, notes, and snippets.

@rat
Last active January 3, 2016 01:49
Show Gist options
  • Save rat/8391359 to your computer and use it in GitHub Desktop.
Save rat/8391359 to your computer and use it in GitHub Desktop.
// lista arquivos no diretorio
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
int main(void)
{
DIR *dir;
struct dirent *lsdir;
dir = opendir("tmp//");
/* print all the files and directories within directory */
while ( ( lsdir = readdir(dir) ) != NULL )
{
printf ("%s\n", lsdir->d_name);
}
closedir(dir);
return 0;
}
//renomeia tmp para lol
#include <stdio.h>
int main()
{
rename("tmp\\", "lol");
return 0;
}
#include <stdlib.h>
#include <io.h>
#define TMP_DIR "spool/"
int main(void){
if (access(TMP_DIR, F_OK) != -1) {
rename(TMP_DIR, "outgoing/");
}
return 0;
}
<?php
// Checks whether the directory exists
if (!file_exists('tmp/')) {
mkdir('tmp/', 0777, true);
}
// Make file
while (true) {
$filename = uniqid(rand());
if (!file_exists('tmp/' . $filename)) {
$file = fopen('tmp/' . $filename, 'w');
fwrite($file, $_POST['phone'] . PHP_EOL . $_POST['sms']);
fclose($file);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment