Added file handling

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2020-04-29 22:55:46 +02:00
parent 5e12445ac7
commit 022e400a2a
No known key found for this signature in database
GPG key ID: 81EC9BAC5E9667C6
2 changed files with 88 additions and 0 deletions

44
include/file.h Normal file
View file

@ -0,0 +1,44 @@
/*
* file.h - File writing functionality
* The author licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef FILE_H
#define FILE_H
char* generate_safe_dirname(){
/* Get time */
time_t rawtime;
struct tm *info;
time( &rawtime );
info = localtime( &rawtime );
#define TIME_LEN 30
char datestr[TIME_LEN];
if(datestr == NULL){
return NULL;
}
strftime(datestr, TIME_LEN, "%FT%T%z", info);
#undef TIME_LEN
}
#endif /* FILE_H */

44
src/file.c Normal file
View file

@ -0,0 +1,44 @@
/*
* file.h - File writing functionality
* The author licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef FILE_H
#define FILE_H
char* generate_safe_dirname(){
/* Get time */
time_t rawtime;
struct tm *info;
time( &rawtime );
info = localtime( &rawtime );
#define TIME_LEN 30
char datestr[TIME_LEN];
if(datestr == NULL){
return NULL;
}
strftime(datestr, TIME_LEN, "%FT%T%z", info);
#undef TIME_LEN
}
#endif /* FILE_H */