Commit Graph

52 Commits

Author SHA1 Message Date
psychon
4e767b3ea7 Make CFile::Seek() take an off_t as param, not an unsigned long
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1458 726aef4b-f618-498e-8847-2d620e286838
2009-03-31 07:34:42 +00:00
psychon
fa285b7cf9 Switch some more CFile members to more appropriate return types
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1454 726aef4b-f618-498e-8847-2d620e286838
2009-03-30 09:03:54 +00:00
psychon
5eed1f43b8 Change the return type of CFile::Get*Time() to time_t, which is more correct
Thanks to KiNgMaR for the patch.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1453 726aef4b-f618-498e-8847-2d620e286838
2009-03-30 08:27:23 +00:00
psychon
860ccb7dec Remove/fix some dead code
All of this was found via warnings ("remarks") from icc.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1435 726aef4b-f618-498e-8847-2d620e286838
2009-03-20 10:00:31 +00:00
psychon
f618ce2a8d Add CFile::Sync()
This adds a simple wrapper for fsync() to CFileUtils.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1431 726aef4b-f618-498e-8847-2d620e286838
2009-03-18 15:40:05 +00:00
silverleo
ada9b8cf97 CFile::IsDir failed for the root directory "/". This patch fixes that special case.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1404 726aef4b-f618-498e-8847-2d620e286838
2009-02-27 20:58:34 +00:00
psychon
70b60aa451 Some cleanup to CFile
Remove CFile::SetFD() which was unused and made FD leaks way too easy.

Remove CFile::CFile(int fd, const CString& sLongName) since it's unused and
it was the only reason we needed the m_bClose member which is now also gone.

Call ClearBuffer() in Close() in case someone reuses CFile instances.

Thanks to Sebastinas.



git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1383 726aef4b-f618-498e-8847-2d620e286838
2009-02-17 15:29:06 +00:00
psychon
b17bfe7922 Make CFile::ReadFile() actually honour the max file size we give it
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1366 726aef4b-f618-498e-8847-2d620e286838
2009-02-03 18:18:05 +00:00
psychon
422ab3288e Make CExecSock generate error messages if execvp() fails to find sh
I doubt this will ever happen, but let's better be sure...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1362 726aef4b-f618-498e-8847-2d620e286838
2009-02-02 15:20:44 +00:00
psychon
9a8fbdb6e0 Just ignore this
This commit never happened.
You must be dreaming.
Really, there is nothing to see here.
Still here? Go away!
Ok, I suck, feeling better now?


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1356 726aef4b-f618-498e-8847-2d620e286838
2009-01-29 15:41:38 +00:00
psychon
f7825e0016 Make CFile::IsDir() work on those weird OS that don't like trailing slashes
Yeah, I'm talking windows here.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1355 726aef4b-f618-498e-8847-2d620e286838
2009-01-29 15:39:26 +00:00
psychon
e6ede6decb Use O_BINARY when opening files if it is available
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1354 726aef4b-f618-498e-8847-2d620e286838
2009-01-28 09:55:32 +00:00
psychon
235b10c200 Use that new define everywhere
Now there are no uses of DEBUG_ONLY() left :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1349 726aef4b-f618-498e-8847-2d620e286838
2009-01-25 16:51:54 +00:00
psychon
fb54bc2fc4 Cleanup: Remove an unnecessary scope operator
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1341 726aef4b-f618-498e-8847-2d620e286838
2009-01-23 13:50:53 +00:00
psychon
accb2e46c9 Check if lstat() is available and use stat() instead if it isn't
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1339 726aef4b-f618-498e-8847-2d620e286838
2009-01-22 11:19:42 +00:00
psychon
127347825e Remove CLockFile and let CFile do its job
This shouldn't contain any major behaviour change, but there are some minor
ones. Also, the API for a shared lock wasn't used and thus is dropped.

Thanks to cnu for this idea.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1337 726aef4b-f618-498e-8847-2d620e286838
2009-01-20 13:21:29 +00:00
psychon
6345ce12fa Make O_RDONLY the default mode when opening files through CFile
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1336 726aef4b-f618-498e-8847-2d620e286838
2009-01-19 15:55:41 +00:00
psychon
36505a8d29 access() is evil and we never want a controlling TTY
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1318 726aef4b-f618-498e-8847-2d620e286838
2009-01-02 17:48:20 +00:00
psychon
08ad0291ea Happy New Year 2009 everyone!
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1317 726aef4b-f618-498e-8847-2d620e286838
2009-01-01 12:22:21 +00:00
psychon
69279c516e Use fchmod() instead of chmod() if the file is already open
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1316 726aef4b-f618-498e-8847-2d620e286838
2008-12-31 14:34:55 +00:00
psychon
b7f38c4d4a Remove some code duplications and move functions into classes
This removes ReadFile(), WriteFile(), ReadLine(), Lower() and Upper() from
Utils.h and adds CFile::ReadFile().

The biggest part of this patch fixes modules to use CFile and CString instead
of these global functions.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1311 726aef4b-f618-498e-8847-2d620e286838
2008-12-30 13:05:04 +00:00
psychon
751f267f30 Improve CFile::ReadLine() a little
IMHO it is now a little clearer how this function works and it might be
a little faster. Biggest change is that we now read 4k of the file at once
instead of reading it in 64byte chunks. I doubt that this causes a lot more
memory usage, because CFile instances usually dont live for long, but it
should really lower the number of syscalls we need for reading a file.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1306 726aef4b-f618-498e-8847-2d620e286838
2008-12-28 13:03:43 +00:00
silverleo
9bec4b8048 Fix a bug introduced in r1280
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1287 726aef4b-f618-498e-8847-2d620e286838
2008-12-09 20:25:34 +00:00
psychon
e6007747d7 Handle read errors in CFile::Copy()
This fixes an endless loop (However, I don't know how it happened).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1280 726aef4b-f618-498e-8847-2d620e286838
2008-12-06 14:49:56 +00:00
psychon
b16e3ebe6c Replace CDir::MakeDir() with a version that doesn't do chdir()
This means that ZNC now doesn't break with relative data dirs (for me)
any more!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1045 726aef4b-f618-498e-8847-2d620e286838
2008-05-08 17:47:55 +00:00
psychon
01bc68b1cb Move ChangeDir() and MakeDir() from CUtils to CDir
Those function were not modified. Only change is the name.

Those *Dir() functions really made no sense in CUtils when there is FileUtils
stuff. They really fit much better into here. I'll bet they'll make new friends
fast. I mean, why shouldn't they?
Uhm... sorry ;)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1044 726aef4b-f618-498e-8847-2d620e286838
2008-05-08 16:58:32 +00:00
psychon
c64d7bc108 Force a space between if, for, while and (
This was done via:
   sed -ir 's/if(/if (/g; s/for(/for (/g; s/while(/while (/g' \
        *.h *.cpp modules/*.cpp



git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1030 726aef4b-f618-498e-8847-2d620e286838
2008-04-20 13:08:44 +00:00
psychon
b0a1714b86 Remove useless spaces inside of braces "( stuff )"
This was generated via the following command:

  cat <file> | \
  tr "\n" "€"| \
  sed -r 's/€[\t ]*\{€/ {€/g; s/\( */(/g; s/ *\)/)/g' | \
  tr "€" "\n"

Thanks to SilverLeo for producing this mess :P


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1029 726aef4b-f618-498e-8847-2d620e286838
2008-04-20 13:00:19 +00:00
psychon
73d8456dff Mark all FDs as close-on-exec
This marks all FDs which are valid after the function creating them returns
as close-on-exec, so that processes started from ZNC (e.g. through the shell
module) don't inherit a copy of all of our FDs.

Csocket already does this for its FDs.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1004 726aef4b-f618-498e-8847-2d620e286838
2008-04-01 08:52:13 +00:00
psychon
f74ab87e19 And fix a shitload of trailing whitespaces and space / tab mixups in ZNC
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@959 726aef4b-f618-498e-8847-2d620e286838
2008-02-16 12:52:11 +00:00
psychon
f495acd110 Make CFile::Delete() return a bool (true for success)
The static version of CFile::Delete() already does so.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@946 726aef4b-f618-498e-8847-2d620e286838
2008-02-08 16:20:20 +00:00
psychon
e72c445694 Clean up includes
All the headers are now self-contained (g++ Header.h -o /dev/null).

Some system headers where moved to the .cpp they are actually needed in,
some of our own headers are includes less. (Especially MD5.h)

Headers are sorted alphabetically while in e.g. FileUtils.cpp FileUtils.h
is the first file included.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@915 726aef4b-f618-498e-8847-2d620e286838
2008-01-07 21:31:16 +00:00
psychon
eeec633e30 Update copyright header for 2008
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@910 726aef4b-f618-498e-8847-2d620e286838
2008-01-07 21:13:07 +00:00
psychon
b490b12058 Fix some gcc 4.3 warnings
These are mostly string casts, handling function's return value and some
weird warning about missing spaces on empty while loops.

These were reported by and fixed with Marcus Rueckert <darix@opensu.se>.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@904 726aef4b-f618-498e-8847-2d620e286838
2007-12-20 18:31:48 +00:00
psychon
a09a7e79f6 Switch to the copyright headers the GPLv2 wants us to have
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@843 726aef4b-f618-498e-8847-2d620e286838
2007-09-21 18:55:33 +00:00
prozacx
0a62274975 Committing patches from crox/psychon
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@790 726aef4b-f618-498e-8847-2d620e286838
2007-03-12 06:26:54 +00:00
imaginos
e522c7f22d check to see whats remaining in buffer and return true
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@782 726aef4b-f618-498e-8847-2d620e286838
2006-09-23 17:58:49 +00:00
imaginos
c2b8b7c685 added delimiter support and fixed an eof bug
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@781 726aef4b-f618-498e-8847-2d620e286838
2006-09-23 14:05:18 +00:00
prozacx
6dcacaa79e Added contact info
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@752 726aef4b-f618-498e-8847-2d620e286838
2006-09-13 07:39:48 +00:00
imaginos
365912693c fix initialization for execvp to const type
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@741 726aef4b-f618-498e-8847-2d620e286838
2006-07-10 02:48:57 +00:00
imaginos
775df4f8cf switch to execvp, as system() does its own fork and can cause process to detach completely if parent process dies
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@677 726aef4b-f618-498e-8847-2d620e286838
2006-03-04 09:25:27 +00:00
imaginos
d456374e80 made CExecSock into a base class
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@675 726aef4b-f618-498e-8847-2d620e286838
2006-03-04 05:21:07 +00:00
prozacx
81eef38929 Made some helper funcs const
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@619 726aef4b-f618-498e-8847-2d620e286838
2006-02-08 08:41:45 +00:00
prozacx
a4ca68f6f4 Init fd to -1
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@608 726aef4b-f618-498e-8847-2d620e286838
2006-02-06 02:10:21 +00:00
prozacx
ecf431f246 Added CTemplate support which included upgrading String.cpp/h and FileUtils.cpp/h and fixing some issues
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@603 726aef4b-f618-498e-8847-2d620e286838
2006-02-05 05:01:53 +00:00
prozacx
6b4b543808 Upped buffer to 8192 in Copy()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@448 726aef4b-f618-498e-8847-2d620e286838
2005-07-18 04:12:09 +00:00
prozacx
6be9f989cb Added Copy()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@447 726aef4b-f618-498e-8847-2d620e286838
2005-07-18 04:11:09 +00:00
prozacx
653fe468f0 Renamed RightTrim() to TrimRight()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@408 726aef4b-f618-498e-8847-2d620e286838
2005-07-04 23:27:08 +00:00
prozacx
9db44ab1fe Added SetFileName()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@401 726aef4b-f618-498e-8847-2d620e286838
2005-07-01 18:50:53 +00:00
prozacx
078bbcf019 Moved some more functions from CUtils into CString
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@246 726aef4b-f618-498e-8847-2d620e286838
2005-05-07 11:42:10 +00:00