mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-13 06:12:49 -06:00
git-svn-id: svn://ultimatepp.org/upp/trunk@1760 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9a1d38fb50
commit
2c805d902e
7 changed files with 1 additions and 1620 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,382 +0,0 @@
|
|||
#ifndef _Functions4U_Functions4U_h
|
||||
#define _Functions4U_Functions4U_h
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
bool FileCat(const char *file, const char *appendFile);
|
||||
|
||||
bool FileStrAppend(const char *file, const char *str);
|
||||
|
||||
bool DeleteFolderDeepWildcards(const char *dir);
|
||||
|
||||
String GetUpperFolder(String folderName);
|
||||
|
||||
bool CreateFolderDeep(const char *dir);
|
||||
|
||||
bool DirectoryCopy(const char *dir, const char *newPlace);
|
||||
|
||||
bool FileSetReadOnly(String fileName, bool readOnly);
|
||||
|
||||
String LoadFile_Safe(String fileName);
|
||||
|
||||
int64 GetLength(String fileDirName);
|
||||
int64 GetDirectoryLength(String directoryName);
|
||||
|
||||
Array<String> SearchFile(String dir, String condFile, String text, Array<String> &errorList);
|
||||
Array<String> SearchFile(String dir, String condFile, String text = "");
|
||||
|
||||
bool FileToTrashBin(const char *path);
|
||||
int64 TrashBinGetCount();
|
||||
bool TrashBinClear();
|
||||
|
||||
String GetExtExecutable(String ext);
|
||||
|
||||
String GetDesktopFolder();
|
||||
String GetProgramsFolder();
|
||||
String GetAppDataFolder();
|
||||
String GetMusicFolder();
|
||||
String GetPicturesFolder();
|
||||
String GetVideoFolder();
|
||||
String GetPersonalFolder();
|
||||
String GetTemplatesFolder();
|
||||
String GetDownloadFolder();
|
||||
String GetRootFolder();
|
||||
String GetTempFolder();
|
||||
String GetOsFolder();
|
||||
String GetSystemFolder();
|
||||
|
||||
|
||||
struct FileData : Moveable<FileData> {
|
||||
bool isFolder;
|
||||
String fileName;
|
||||
String relFilename;
|
||||
int64 length;
|
||||
struct Upp::Time t;
|
||||
int64 id;
|
||||
|
||||
String ToString() const { return Format("%s %0n", fileName, length); }
|
||||
|
||||
FileData(bool isFolder, String fileName, String relFilename, int64 length, struct Upp::Time t, uint64 id) : isFolder(isFolder), fileName(fileName), relFilename(relFilename), length(length), t(t), id(id) {}
|
||||
FileData() {}
|
||||
};
|
||||
|
||||
struct FileDiff {
|
||||
char action; // 'n': New, 'u': Update, 'd': Delete, 'p': Problem
|
||||
bool isFolder;
|
||||
String relPath;
|
||||
String fileName;
|
||||
uint64 idMaster, idSecondary;
|
||||
struct Upp::Time tMaster, tSecondary;
|
||||
uint64 lengthMaster, lengthSecondary;
|
||||
};
|
||||
|
||||
class ErrorHandling
|
||||
{
|
||||
public:
|
||||
void SetLastError(String _lastError) {lastError = _lastError;};
|
||||
String GetLastError() {return lastError;};
|
||||
|
||||
private:
|
||||
String lastError;
|
||||
};
|
||||
|
||||
class FileDiffArray;
|
||||
|
||||
class FileDataArray : public ErrorHandling
|
||||
{
|
||||
public:
|
||||
FileDataArray(bool use = false);
|
||||
bool Init(String folder, FileDataArray &orig, FileDiffArray &diff);
|
||||
void Clear();
|
||||
bool Search(String dir, String condFile, bool recurse = false, String text = "");
|
||||
FileData& operator[](long i) {return fileList[i];}
|
||||
long GetFileCount() {return fileCount;};
|
||||
long GetFolderCount() {return folderCount;};
|
||||
long GetCount() {return fileCount + folderCount;};
|
||||
int64 GetSize() {return fileSize;};
|
||||
inline bool UseId() {return useId;};
|
||||
void SortByName(bool ascending = true);
|
||||
void SortByDate(bool ascending = true);
|
||||
void SortBySize(bool ascending = true);
|
||||
Array<String> &GetLastError() {return errorList;};
|
||||
int Find(String &relFileName, String &fileName, bool isFolder);
|
||||
String FullFileName(int i) {return AppendFileName(basePath, fileList[i].fileName);};
|
||||
bool SaveFile(const char *fileName);
|
||||
bool LoadFile(const char *fileName);
|
||||
|
||||
private:
|
||||
void Search_Each(String dir, String condFile, bool recurse, String text);
|
||||
int64 GetFileId(String fileName);
|
||||
String GetRelativePath(String fullPath);
|
||||
|
||||
Array<FileData> fileList;
|
||||
Array<String> errorList;
|
||||
String basePath;
|
||||
long fileCount, folderCount;
|
||||
int64 fileSize;
|
||||
bool useId;
|
||||
};
|
||||
|
||||
class FileDiffArray : public ErrorHandling
|
||||
{
|
||||
public:
|
||||
FileDiffArray();
|
||||
void Clear();
|
||||
FileDiff& operator[](long i) {return diffList[i];}
|
||||
bool Compare(FileDataArray &master, FileDataArray &secondary);
|
||||
bool Apply(String toFolder, String fromFolder);
|
||||
long GetCount() {return diffList.GetCount();};
|
||||
bool SaveFile(const char *fileName);
|
||||
bool LoadFile(const char *fileName);
|
||||
String ToString();
|
||||
|
||||
private:
|
||||
Array<FileDiff> diffList;
|
||||
};
|
||||
|
||||
|
||||
String Replace(String str, String find, String replace);
|
||||
|
||||
int ReverseFind(const String& s, const String& toFind, int from = 0);
|
||||
|
||||
String FormatLong(long a);
|
||||
|
||||
const char *StrToTime(struct Upp::Time& d, const char *s);
|
||||
|
||||
String BytesToString(uint64 bytes);
|
||||
|
||||
String SecondsToString(double seconds, bool units = false);
|
||||
String HMSToString(int hour, int min, double seconds, bool units = false);
|
||||
double StringToSeconds(String str); // The opposite
|
||||
void StringToHMS(String durat, int &hour, int &min, double &seconds);
|
||||
|
||||
inline double ToRad(double angle) {return angle*M_PI/180;}
|
||||
|
||||
inline bool Odd(int val) {return val%2;}
|
||||
inline bool Even(int val) {return !Odd(val);}
|
||||
inline int RoundEven(int val) {return Even(val) ? val : val+1;}
|
||||
template<class T>
|
||||
inline int Sign(T a) {return (a > 0) - (a < 0);}
|
||||
|
||||
int DayOfYear(Date d);
|
||||
|
||||
|
||||
// Fits object centered into frame maintaining the aspect
|
||||
template <class T>
|
||||
Rect_<T> FitInFrame(const Size_<T> &frame, const Size_<T> &object)
|
||||
{
|
||||
double frameAspect = frame.cx/(double)frame.cy;
|
||||
double objectAspect = object.cx/(double)object.cy;
|
||||
|
||||
if (frameAspect > objectAspect) {
|
||||
double x = (frame.cx - objectAspect*frame.cy)/2.;
|
||||
return Rect_<T>((T)x, 0, (T)(x + objectAspect*frame.cy), frame.cy);
|
||||
} else {
|
||||
double y = (frame.cy - frame.cx/objectAspect)/2.;
|
||||
return Rect_<T>(0, (T)y, frame.cx, (T)(y + frame.cx/objectAspect));
|
||||
}
|
||||
}
|
||||
|
||||
Color RandomColor();
|
||||
|
||||
// A String based class to parse into
|
||||
class StringParse : public String {
|
||||
public:
|
||||
void GoInit() {pos = 0; lastSeparator='\0';};
|
||||
StringParse():String("") {GoInit();};
|
||||
StringParse(String s): String(s) {GoInit();};
|
||||
bool GoBefore(const String text)
|
||||
{
|
||||
if (pos >= GetLength()) {
|
||||
pos = GetLength()-1;
|
||||
return false;
|
||||
}
|
||||
int newpos = String::Find(text, pos);
|
||||
if (newpos < 0)
|
||||
return false; // If it does not find it, it does not move
|
||||
pos = newpos;
|
||||
return true;
|
||||
};
|
||||
bool GoAfter(const String text)
|
||||
{
|
||||
if(!GoBefore(text))
|
||||
return false;
|
||||
pos += strlen(text);
|
||||
return true;
|
||||
};
|
||||
bool GoAfter(const String text, const String text2)
|
||||
{
|
||||
if(!GoAfter(text))
|
||||
return false;
|
||||
if(!GoAfter(text2))
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
bool GoAfter(const String text, const String text2, const String text3)
|
||||
{
|
||||
if(!GoAfter(text))
|
||||
return false;
|
||||
if(!GoAfter(text2))
|
||||
return false;
|
||||
if(!GoAfter(text3))
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
bool GoAfter_Init(const String text) {GoInit(); return GoAfter(text);};
|
||||
bool GoAfter_Init(const String text, const String text2) {GoInit(); return GoAfter(text, text2);};
|
||||
bool GoAfter_Init(const String text, const String text2, const String text3) {GoInit(); return GoAfter(text, text2, text3);};
|
||||
|
||||
void GoBeginLine()
|
||||
{
|
||||
for (; pos >= 0; --pos) {
|
||||
if ((ToString()[pos-1] == '\r') || (ToString()[pos-1] == '\n'))
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool IsBeginLine()
|
||||
{
|
||||
if (pos == 0)
|
||||
return true;
|
||||
if ((ToString()[pos-1] == '\r') || (ToString()[pos-1] == '\n'))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool IsSpaceRN(int c)
|
||||
{
|
||||
if (IsSpace(c))
|
||||
return true;
|
||||
if ((c == '\r') || (c == '\n'))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// Gets text between "" or just a word until an space
|
||||
// It considers special characters with \ if between ""
|
||||
// If not between "" it gets the word when it finds one of the separator characters
|
||||
String GetText(String separators = "")
|
||||
{
|
||||
String ret = "";
|
||||
if (pos > GetCount())
|
||||
return ret;
|
||||
int newpos = pos;
|
||||
|
||||
while ((IsSpaceRN(ToString()[newpos]) && (ToString()[newpos] != '\"') &&
|
||||
(ToString()[newpos] != '\0')))
|
||||
newpos++;
|
||||
if (ToString()[newpos] == '\0') {
|
||||
pos = newpos;
|
||||
return "";
|
||||
}
|
||||
|
||||
if (ToString()[newpos] == '\"') { // Between ""
|
||||
newpos++;
|
||||
while (ToString()[newpos] != '\"' && ToString()[newpos] != '\0') {
|
||||
if (ToString()[newpos] == '\\') {
|
||||
newpos++;
|
||||
if (ToString()[newpos] == '\0')
|
||||
return "";
|
||||
}
|
||||
ret.Cat(ToString()[newpos]);
|
||||
newpos++;
|
||||
}
|
||||
lastSeparator = '"';
|
||||
} else if (separators == "") { // Simple word
|
||||
while (!IsSpaceRN(ToString()[newpos]) && ToString()[newpos] != '\0') {
|
||||
if (ToString()[newpos] == '\"') {
|
||||
newpos--; // This " belongs to the next
|
||||
break;
|
||||
}
|
||||
ret.Cat(ToString()[newpos]);
|
||||
newpos++;
|
||||
}
|
||||
lastSeparator = ToString()[newpos];
|
||||
} else { // Simple word, special separator
|
||||
while (ToString()[newpos] != '\0') {// Only consider included spaces (!IsSpaceRN(ToString()[newpos]) && ToString()[newpos] != '\0') {
|
||||
if (ToString()[newpos] == '\"') {
|
||||
newpos--; // This " belongs to the next
|
||||
break;
|
||||
}
|
||||
if (separators.Find(ToString()[newpos]) >= 0) {
|
||||
lastSeparator = ToString()[newpos];
|
||||
break;
|
||||
}
|
||||
ret.Cat(ToString()[newpos]);
|
||||
newpos++;
|
||||
}
|
||||
lastSeparator = ToString()[newpos];
|
||||
}
|
||||
pos = ++newpos; // After the separator: ", space or separator
|
||||
return ret;
|
||||
}
|
||||
String GetLine()
|
||||
{
|
||||
return GetText("\r\n");
|
||||
}
|
||||
double GetDouble(String separators = "") {return atof(GetText(separators));};
|
||||
int GetInt(String separators = "") {return atoi(GetText(separators));};
|
||||
long GetLong(String separators = "") {return atol(GetText(separators));};
|
||||
uint64 GetUInt64(String separators = "")
|
||||
#if defined(PLATFORM_WIN32)
|
||||
{return _atoi64(GetText(separators));};
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
{return atoll(GetText(separators));};
|
||||
#endif
|
||||
|
||||
String Right() {return String::Right(GetLength()-pos);}
|
||||
int GetLastSeparator() {return lastSeparator;}
|
||||
void MoveRel(int val)
|
||||
{
|
||||
pos += val;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
else if (pos >= GetCount())
|
||||
pos = GetCount() - 1;
|
||||
}
|
||||
int GetPos() {return pos;};
|
||||
bool SetPos(int i)
|
||||
{
|
||||
if (i < 0 || i >= GetCount())
|
||||
return false;
|
||||
else {
|
||||
pos = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool Eof()
|
||||
{
|
||||
return pos >= GetCount();
|
||||
}
|
||||
unsigned Count(String s)
|
||||
{
|
||||
int from = 0;
|
||||
unsigned count = 0;
|
||||
|
||||
while ((from = ToString().Find(s, from)) >= 0) {
|
||||
count++;
|
||||
from++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
private:
|
||||
int pos;
|
||||
int lastSeparator;
|
||||
};
|
||||
|
||||
#if defined(PLATFORM_WIN32)
|
||||
Value GetVARIANT(VARIANT &result);
|
||||
#endif
|
||||
|
||||
#ifdef CTRLLIB_H
|
||||
#include "Functions4U/Functions4U_Gui.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
// A ProcessEvents than can be used in non gui programs
|
||||
inline void DoEvents() {
|
||||
#ifdef CTRLLIB_H
|
||||
Ctrl::ProcessEvents();
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#ifdef _MSC_VER
|
||||
#pragma setlocale("C")
|
||||
#endif
|
||||
// Functions4U.cpp
|
||||
|
||||
T_("hours")
|
||||
esES("horas")
|
||||
|
||||
T_("hour")
|
||||
esES("hora")
|
||||
|
||||
T_("mins")
|
||||
esES("mins")
|
||||
|
||||
T_("min")
|
||||
esES("min")
|
||||
|
||||
T_("secs")
|
||||
esES("segs")
|
||||
|
||||
T_("sec")
|
||||
esES("seg")
|
||||
|
||||
T_("Impossible to open file")
|
||||
esES("Imposible abrir fichero")
|
||||
|
||||
T_("Problem found")
|
||||
esES("Problema encontrado")
|
||||
|
||||
T_("Not possible to create")
|
||||
esES("No es posible crear")
|
||||
|
||||
T_("Not possible to delete")
|
||||
esES("No es posible borrar")
|
||||
|
||||
T_("There was a problem in the copy")
|
||||
esES("Hubo un problema al copiar")
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
description "Functions and classes for general use\377B255,170,0";
|
||||
|
||||
uses
|
||||
Core;
|
||||
|
||||
library(WIN32) "oleaut32 ";
|
||||
|
||||
file
|
||||
Functions4U.cpp,
|
||||
Functions4U.h,
|
||||
Functions4U_Gui.cpp,
|
||||
Functions4U_Gui.h,
|
||||
srcdoc.tpp,
|
||||
src.tpp,
|
||||
Functions4U.t,
|
||||
License.txt;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#ifdef flagGUI
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
#include "Functions4U.h"
|
||||
#include "Functions4U/Functions4U_Gui.h"
|
||||
|
||||
inline const RGBA *GetPixel(Image &img, int x, int y) {
|
||||
return img + x + y*img.GetWidth();
|
||||
}
|
||||
|
||||
inline RGBA *GetPixel(ImageBuffer &img, int x, int y) {
|
||||
return img + x + y*img.GetWidth();
|
||||
}
|
||||
|
||||
Image Rotate180(const Image& orig) {
|
||||
Size sz = orig.GetSize();
|
||||
ImageBuffer dest(sz);
|
||||
for(int rw = 0; rw < sz.cy; rw++)
|
||||
for(int cl = 0; cl < sz.cx; cl++)
|
||||
dest[rw][cl] = orig[sz.cy - rw - 1][sz.cx - cl - 1];
|
||||
return dest;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef _Functions4U_Functions4U_Gui_h_
|
||||
#define _Functions4U_Functions4U_Gui_h_
|
||||
|
||||
const RGBA *GetPixel(Image &img, int x, int y);
|
||||
RGBA *GetPixel(ImageBuffer &img, int x, int y);
|
||||
|
||||
Image Rotate180(const Image& img);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<<<<<<< .mine
|
||||
Copyright 2009 Functions4U by Koldo contributed for U++ Project. All rights reserved.
|
||||
Copyright 2009 Controls4U by Koldo contributed for U++ Project. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue