summaryrefslogtreecommitdiff
path: root/algorithm.h
blob: 31c7e9ca60885816559d93f002fd83b81affc7bf (plain)
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
#ifndef ALGORITHM_H_INCLUDED
#define ALGORITHM_H_INCLUDED

#include "FreeFileSync.h"
#include "library/statusHandler.h"


namespace FreeFileSync
{
    wxString formatFilesizeToShortString(const wxULongLong& filesize);
    wxString formatFilesizeToShortString(const double filesize);
    Zstring getFormattedDirectoryName(const Zstring& dirname);

    void swapGrids(FileCompareResult& grid);

    void adjustModificationTimes(const Zstring& parentDirectory, const int timeInSeconds, ErrorHandler* errorHandler) throw(AbortThisProcess);

    void deleteOnGridAndHD(FileCompareResult& grid, const std::set<int>& rowsToDelete, ErrorHandler* errorHandler, const bool useRecycleBin) throw(AbortThisProcess);
    void addSubElements(std::set<int>& subElements, const FileCompareResult& grid, const FileCompareLine& relevantRow);

    void filterCurrentGridData(FileCompareResult& currentGridData, const wxString& includeFilter, const wxString& excludeFilter);
    void removeFilterOnCurrentGridData(FileCompareResult& currentGridData);

    wxString utcTimeToLocalString(const time_t utcTime);

    //enhanced binary search template: returns an iterator
    template <class ForwardIterator, class T>
    ForwardIterator custom_binary_search (ForwardIterator first, ForwardIterator last, const T& value)
    {
        first = lower_bound(first, last, value);
        if (first!=last && !(value<*first))
            return first;
        else
            return last;
    }

#ifdef FFS_WIN
    bool isFatDrive(const Zstring& directoryName);

//detect if FAT/FAT32 drive needs a +-1h time shift after daylight saving time (DST) switch due to known windows bug:
//http://www.codeproject.com/KB/datetime/dstbugs.aspx

//NO performance issue: debug build: 50 ms for 200000 files processed in for-loop
    void checkForDSTChange(const FileCompareResult& gridData, const std::vector<FolderPair>& directoryPairsFormatted, int& timeShift, wxString& driveName);
#endif  //FFS_WIN

}


#endif // ALGORITHM_H_INCLUDED
bgstack15