-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfilename.h
77 lines (57 loc) · 2.41 KB
/
filename.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**************************************************************************
* copyright : (C) 2004-2006 by Petr Schwarz & Pavel Matejka *
* UPGM,FIT,VUT,Brno *
* email : {schwarzp,matejkap}@fit.vutbr.cz *
**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#ifndef _FILENAME_H
#define _FILENAME_H
#include <stdio.h>
#if defined WIN32 && !defined __CYGWIN__
#include <io.h>
#else
#include <unistd.h>
#include <sys/types.h>
#endif
// /dir/file.doc -> /dir/file.txt
void ChangeFileSuffix(char *fileName, char *newSuffix);
// /dir/file.txt -> /new_dir/file.txt
void ChangeFilePath(char *fileName, char *newPath);
// /dir/file.txt -> file.txt
void ExtractFileName(char *fileName);
// /dir/file.txt -> file
void ExtractBaseFileName(char *fileName);
// /dir/file.txt -> /dir/file
void CutOffFileSuffix(char *fileName);
// /dir/file.txt -> txt
void GetFileSuffix(char *fileName, char *retSuffix);
// /dir/file.txt -> /dir
void GetFilePath(char *fileName, char *retPath);
// *dSep = '\\' => /dir/file.txt -> \\dir\\file.txt
void CorrectDirSeparator(char *fileName, const char *dSep);
// check whether the file exists
bool FileExistence(char *fileName);
// check whether the file has write permition
bool FileWritePerm(char *file);
// check whether the file exists and can be opened with exclusive permission
bool FileExclPerm(char *fileName);
// returns file length
long FileLen(FILE *fp);
// copy file
bool FileCopy(char *from, char *to, bool overwrite = true);
// move file
bool FileMove(char *from, char *to);
// prevDir = /dir
// newDir = /dirx
// /dir1/dir2/file.txt -> /dirx/dir2/file.txt
bool SubstFileDir(char *fileName, char *prevDir, char *newDir);
// channelSuffix = _L
// /dir/file.txt -> /dir/file_L.txt
void CreateChannelFileName(char *file, char *channelSuffix);
#endif