#include <stdlib.h>#include <stdio.h>#include <time.h>#include <ctype.h>#include <math.h>#include <errno.h>#include <unistd.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <dirent.h>#include "common.h"
Go to the source code of this file.
Functions | |
| void | CloseInput (void) |
| close the input file | |
| FILE * | InitEventList (const char *fn) |
| Initialize the eventlist file Try to open the file. | |
| time_t | NextWindow (void) |
| Look for the next data window The input is parsed for the next data window according to the method used (timelist, timesegment, command line. | |
| int | SequentialSeek (time_t t) |
| seek a time using a sequential search in a sorted list (day or daydir) | |
| int | SeekTime (time_t t) |
| Seek a time in the input data Scan the cache file, find the offset for the latest time entry before the requested time, open the corresponding file and seek in this file. | |
| int | TitanFileSelect (const struct dirent *t) |
| Select filenames matching the titan2 file pattern: hh.mm.ss. | |
| int | DayDirSelect (const struct dirent *t) |
| Select filenames matching the titan2 day dir pattern: YYYY.MM.DD. | |
| void | FreeDiskDir (void) |
| free the dayDir table | |
| int | OpenDiskDir (const char *path) |
| Open a disk directory, reads the content and build the day dir list The list will be used by NextFile(). | |
| void | FreeDayDir (void) |
| free the file list | |
| int | OpenDayDir (const char *path) |
| Open a day directory, reads the content and build the file list The list will be used by NextFile(). | |
| FILE * | NextFile (void) |
| Determine the next file to open In file mode, the iFileInput defines the index of the next file. | |
| int | OpenTempFile (char *template) |
| open a temp file for writing as mkstemp would do | |
| int | Rename (const char *oldpath, const char *newpath) |
| rename a file, also over different filesystem | |
Variables | |
| int | nFiles = 0 |
| int | trySeek = -1 |
| struct dirent ** | titanList = NULL |
| the list of titan files to be processed | |
| int | titanListLen = 0 |
| the number of files in titanList | |
| int | titanListIndex = 0 |
| the index of the next file to read | |
| struct dirent ** | dayDir = NULL |
| the list of day directory to be processed | |
| int | dayDirLen = 0 |
| the number of day directory in dayDir | |
| int | dayDirIndex = 0 |
| the index of the next directory to open | |
| char | fullName [256] |
| work buffer for the name of the currently processed file | |
| FILE * | eventList = NULL |
| event list: tl= | |
| int | segmentLength = 0 |
| segment length: ts= | |
| void CloseInput | ( | void | ) |
close the input file
Definition at line 54 of file files.c.
References titan2File.
Referenced by EndSuperFrame(), GetFrame(), NextFile(), and ResetInput().
| int DayDirSelect | ( | const struct dirent * | t | ) |
Select filenames matching the titan2 day dir pattern: YYYY.MM.DD.
| t | the element to check |
Definition at line 451 of file files.c.
Referenced by OpenDiskDir().
| void FreeDayDir | ( | void | ) |
free the file list
Definition at line 518 of file files.c.
References titanList, and titanListLen.
Referenced by OpenDayDir(), and ResetInput().
| void FreeDiskDir | ( | void | ) |
free the dayDir table
Definition at line 478 of file files.c.
References dayDir, and dayDirLen.
Referenced by OpenDiskDir(), and ResetInput().
| FILE* InitEventList | ( | const char * | fn | ) |
Initialize the eventlist file Try to open the file.
If it is not possible, just let eventList=NULL
| fn | the file name |
Definition at line 67 of file files.c.
References eventList, and PrintError.
Referenced by ParseOptions().
| FILE* NextFile | ( | void | ) |
Determine the next file to open In file mode, the iFileInput defines the index of the next file.
After opening the file, iFileInput is increased by 1. In daydir mode, the iFileInput defines the index whithin the day directory and we stop if the iFileInput points after the last file. In disk mode, iFileInput defines the index whithin the day directory. If iFileInput points after the last file, the next daydir is processed. If the current daydir was the last one, we stop.
Definition at line 563 of file files.c.
References ARGC, ARGV, baseDir, beginOfFile, CloseInput(), correctedTime, currentFile, DAY_MODE, dayDir, dayDirIndex, dayDirLen, DISK_MODE, endWindow, FILE_BUFFER_SIZE, FILE_MODE, FlushDataFiles(), fullName, iFileInput, INIT_PRINT_TRIGGER, inputMode, inputOffset, nFiles, OpenDayDir(), PrintDebug, PrintError, printTrigger, scanAll, titanList, titanListIndex, titanListLen, totalFrameProcessed, and Titan2TimeType::usecond.
Referenced by GetFrame(), SeekTime(), and SequentialSeek().
| time_t NextWindow | ( | void | ) |
Look for the next data window The input is parsed for the next data window according to the method used (timelist, timesegment, command line.
..). The global variables windowBegin and windowEnd are set accordingly and the begin time is returned.
Definition at line 86 of file files.c.
References beginWindow, cmdLineWindow, endWindow, eventList, postEvent, preEvent, PrintError, PrintLog, str2time(), time2str(), timeSegment, and trySeek.
Referenced by EndSuperFrame(), and main().
| int OpenDayDir | ( | const char * | path | ) |
Open a day directory, reads the content and build the file list The list will be used by NextFile().
| path | the directory to read |
Definition at line 537 of file files.c.
References __alphasort(), __scandir(), baseDir, DAY_MODE, FreeDayDir(), inputMode, TitanFileSelect(), titanList, titanListIndex, and titanListLen.
Referenced by NextFile(), and ParseOptions().
| int OpenDiskDir | ( | const char * | path | ) |
Open a disk directory, reads the content and build the day dir list The list will be used by NextFile().
| path | the directory to read |
Definition at line 497 of file files.c.
References __alphasort(), __scandir(), baseDir, dayDir, dayDirIndex, dayDirLen, DayDirSelect(), DISK_MODE, FreeDiskDir(), and inputMode.
Referenced by ParseOptions().
| int OpenTempFile | ( | char * | template | ) |
open a temp file for writing as mkstemp would do
| template | the same argument as mkstemp |
Definition at line 701 of file files.c.
Referenced by OpenAscChannel(), OpenBinChannel(), OpenCacheFileWrite(), OpenMSeedChannel(), OpenSacChannel(), OpenSeg2Channel(), OpenSegyChannel(), OpenSisBinFile(), OpenTimeFile(), OpenTitBinFile(), and OpenWavChannel().
| int Rename | ( | const char * | oldpath, | |
| const char * | newpath | |||
| ) |
rename a file, also over different filesystem
| oldpath | the source | |
| newfile | the destination |
Definition at line 721 of file files.c.
References PrintError, and SendFile().
Referenced by CheckAlerts(), CloseAscFile(), CloseBinFile(), CloseCacheFile(), CloseMSeedInt32File(), CloseSacFile(), CloseSeg2File(), CloseSegyFile(), CloseTimeFile(), CloseTitFile(), CloseWavFile(), DumpGpsMap(), and DumpTile().
| int SeekTime | ( | time_t | t | ) |
Seek a time in the input data Scan the cache file, find the offset for the latest time entry before the requested time, open the corresponding file and seek in this file.
| t | the file to seek to |
ce test doit-il rester ???
Definition at line 268 of file files.c.
References beginWindow, CacheRead(), correctedTime, currentFile, DAY_MODE, DEFAULT_SERIAL, DISK_MODE, HWConfig, inputMode, NextFile(), OpenCacheFileRead(), PrintDebug, PrintLog, printTrigger, RewindCache(), seeking, SequentialSeek(), HWConfigType::serialNumber, time2str(), titan2File, trySeek, and Titan2TimeType::usecond.
Referenced by ProcessTimeFrame().
| int SequentialSeek | ( | time_t | t | ) |
seek a time using a sequential search in a sorted list (day or daydir)
Definition at line 186 of file files.c.
References correctedTime, currentFile, fastSeek, GetFrame(), NextFile(), PrintDebug, PrintError, printTrigger, seeking, str2time(), titan2File, and Titan2TimeType::usecond.
Referenced by SeekTime().
| int TitanFileSelect | ( | const struct dirent * | t | ) |
Select filenames matching the titan2 file pattern: hh.mm.ss.
| t | the element to check |
Definition at line 421 of file files.c.
Referenced by OpenDayDir().
| struct dirent** dayDir = NULL |
the list of day directory to be processed
Definition at line 45 of file files.c.
Referenced by FreeDiskDir(), NextFile(), and OpenDiskDir().
| int dayDirIndex = 0 |
the index of the next directory to open
Definition at line 47 of file files.c.
Referenced by NextFile(), and OpenDiskDir().
| int dayDirLen = 0 |
the number of day directory in dayDir
Definition at line 46 of file files.c.
Referenced by FreeDiskDir(), NextFile(), and OpenDiskDir().
| FILE* eventList = NULL |
event list: tl=
Definition at line 50 of file files.c.
Referenced by InitEventList(), and NextWindow().
| char fullName[256] |
work buffer for the name of the currently processed file
Definition at line 48 of file files.c.
Referenced by NextFile().
| int nFiles = 0 |
| int segmentLength = 0 |
| struct dirent** titanList = NULL |
the list of titan files to be processed
Definition at line 42 of file files.c.
Referenced by FreeDayDir(), NextFile(), and OpenDayDir().
| int titanListIndex = 0 |
the index of the next file to read
Definition at line 44 of file files.c.
Referenced by NextFile(), and OpenDayDir().
| int titanListLen = 0 |
the number of files in titanList
Definition at line 43 of file files.c.
Referenced by FreeDayDir(), NextFile(), and OpenDayDir().
| int trySeek = -1 |
1.5.6