swad-core/swad_file.h

96 lines
4.0 KiB
C
Raw Permalink Normal View History

2014-12-01 23:55:08 +01:00
// swad_file.h: files
#ifndef _SWAD_FIL
#define _SWAD_FIL
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
2015-10-16 02:24:29 +02:00
#include <stdbool.h> // For boolean type
#include <stdio.h> // For FILE
2016-04-03 01:24:20 +02:00
#include <time.h> // For time_t
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
2017-03-07 11:03:05 +01:00
#define Fil_MIN_BYTES_FILE_EXTENSION 1
#define Fil_MAX_BYTES_FILE_EXTENSION 5
2016-03-28 19:30:37 +02:00
2014-12-01 23:55:08 +01:00
#define Fil_NAME_OF_PARAM_FILENAME_ORG "file"
// Maximum allowed size (in bytes) of a file when uploading it.
// Must be < 2 GiB, because off_t type is of type long int
#define Fil_MAX_FILE_SIZE (2000ULL * 1024ULL * 1024ULL) // 2000 MiB = 1.95 GiB
2014-12-01 23:55:08 +01:00
2017-01-15 22:58:26 +01:00
#define Fil_MAX_BYTES_FILE_SIZE_STRING (32 - 1)
2016-06-30 18:14:09 +02:00
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
FILE *Fil_GetQueryFile (void);
void Fil_SetOutputFileToStdout (void);
FILE *Fil_GetOutputFile (void);
2014-12-21 14:47:04 +01:00
void Fil_CreateFileForHTMLOutput (void);
void Fil_CloseAndRemoveFileForHTMLOutput (void);
2014-12-01 23:55:08 +01:00
bool Fil_ReadStdinIntoTmpFile (void);
void Fil_EndOfReadingStdin (void);
struct Par_Param *Fil_StartReceptionOfFile (const char *ParFile,
char *FileName,char *MIMEType);
bool Fil_EndReceptionOfFile (char *FileNameDataTmp,struct Par_Param *Par);
2017-01-16 01:51:01 +01:00
void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
const char *ExtensionOldName,
char OldName[PATH_MAX + 1],
char NewName[PATH_MAX + 1],
FILE **NewFile);
2019-02-17 01:14:55 +01:00
void Fil_CloseUpdateFile (const char CurrentName[PATH_MAX + 1],
const char OldName[PATH_MAX + 1],
const char NewName[PATH_MAX + 1],
FILE *NewFile);
2016-10-06 22:18:33 +02:00
2014-12-01 23:55:08 +01:00
bool Fil_CheckIfPathExists (const char *Path);
void Fil_CreateDirIfNotExists (const char *Path);
2016-10-06 22:18:33 +02:00
void Fil_RemoveTree (const char *Path);
2019-03-20 13:05:09 +01:00
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,
bool RemoveDirectory);
2014-12-01 23:55:08 +01:00
void Fil_FastCopyOfFiles (const char *PathSrc,const char *PathTgt);
void Fil_FastCopyOfOpenFiles (FILE *FileSrc,FILE *FileTgt);
2016-10-03 14:12:01 +02:00
2016-06-30 18:14:09 +02:00
void Fil_WriteFileSizeBrief (double SizeInBytes,
2017-01-15 22:58:26 +01:00
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1]);
2016-06-30 18:14:09 +02:00
void Fil_WriteFileSizeFull (double SizeInBytes,
2017-01-15 22:58:26 +01:00
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1]);
2016-06-30 18:14:09 +02:00
//------------------------------- File caches ---------------------------------
void Fil_AddPublicDirToCache (const char *FullPathPriv,
const char TmpPubDir[PATH_MAX + 1]);
bool Fil_GetPublicDirFromCache (const char *FullPathPriv,
char TmpPubDir[PATH_MAX + 1]);
2014-12-01 23:55:08 +01:00
#endif