Added file handling
Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
parent
5e12445ac7
commit
022e400a2a
2 changed files with 88 additions and 0 deletions
44
include/file.h
Normal file
44
include/file.h
Normal 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
44
src/file.c
Normal 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 */
|
Loading…
Reference in a new issue