Commit Graph

112 Commits

Author SHA1 Message Date
Lauri Nurmi
b6803cdfd2 Fix double negatives used with 'neither' in docs and comments
In many cases it should be 'either', and 'nor' should be 'or'
accordingly.

No changes to actual code.

See #22723.

(cherry picked from commit 66916c74a3d44e8bc1b30cf42309e36e5d9e9135)
2022-08-19 16:30:25 +02:00
Vadim Zeitlin
cffbea5a0f Don't replace multiple HOME occurrences
Fix another bug in wxFileName::ReplaceHomeDir(): only replace the first
occurrence of the home directory, not all of them (or even the first one
if it appears in the middle of the string).
2022-06-23 21:15:58 +01:00
Vadim Zeitlin
96a917eaa8 Fix wxFileName::ReplaceHomeDir() when HOME=="/"
This is rare but can happen and the function behaved completely wrongly
in this case, so handle it explicitly.

Also disable the unit test when HOME has this value, as it assumes this
is not the case.
2022-06-23 21:15:58 +01:00
Vadim Zeitlin
35d08e6a87 Don't corrupt UNC paths when normalizing with wxPATH_NORM_LONG
After the fixes to UNC paths handling, Normalize(wxPATH_NORM_LONG)
started adding an extra colon after the UNC paths.

Fix this by using wxGetVolumeString() instead of constructing this thing
manually and add a unit test checking for this.

Closes #22275.
2022-04-15 00:32:35 +01:00
Vadim Zeitlin
e50c7b2e2f Add GetDOSPath() helper to wxFileName unit test
No real changes.
2022-04-15 00:13:07 +01:00
Jouk
6c9d1291f6 Fix build under OpenVMS where mkdtemp() is unavailable
Just skip the part of the test using this function under OpenVMS.

Closes #22158.
2022-02-25 18:23:32 +01:00
Scott Talbert
f172f53ac4 Create our own socket file for socket file test
/dev/log doesn't exist in certain types of containers (e.g., Fedora's
build system).  Additionally, this enables us to run this test on
platforms other than Linux.

Closes #22090.
2022-02-05 16:18:22 +01:00
Vadim Zeitlin
d1b5fd27aa Enable long path normalization test by default
It seems that the default value of NtfsDisable8dot3NameCreation registry
value is 2, and not 0, since a very long time (at least Windows 7), so
the wxPATH_NORM_LONG test was never actually executed.

Change the check guarding it to check if the value of the key is
different from 1 instead of checking that it is 0, as the test can still
succeed on the systems where this is the case.

Of course, it can also fail, if short names are disabled for the current
volume, but let's see if this is a problem in practice before doing
something more complicated to deal with this case.
2021-12-10 17:27:06 +01:00
Vadim Zeitlin
b247a1ee70 Use testdata.conf for the wxPATH_NORM_LONG test
This file already exists in the test directory, as it's used by another
test, so just use it instead of relying on the existing of mkinstalldirs
in the parent directory, which is not guaranteed as CMake build runs the
tests from a different directory, which is not the immediate child of
the top source directory.
2021-12-10 17:27:02 +01:00
Vadim Zeitlin
ed19e5625b Fix wxFileName unit test under Unix after recent changes
Don't use GetVolumeSeparator() to combine UNC or GUID volumes with
paths, this doesn't work because this kind of paths doesn't contain
colons at all.

Update the documentation to mention this.
2021-09-15 13:10:25 +02:00
Vadim Zeitlin
e8629db48a Add another test case for wxPATH_NORM_DOTS
This was reported to not work but does work now.

See #15012.
2021-09-15 02:06:30 +01:00
Vadim Zeitlin
549e0a59b1 Fix handling of single letter shares in UNC paths in wxFileName
This comes at the price of breaking compatibility and returning
"\\share" rather than just "share" from wxFileName::GetVolume() for the
UNC paths. This breakage seems justified because it is required in order
to allow application code to distinguish between paths "x:\foo" and
"\\x\foo", which was previously impossible as GetVolume() returned just
"x" in both cases.

Document this change, adjust the existing checks for the new GetVolume()
semantics and add a new test which passes now, but didn't pass before.

Closes #19255.

This commit is best viewed ignoring whitespace-only changes.
2021-09-15 01:51:35 +01:00
Vadim Zeitlin
abf26b03a7 Fix wxFileName::Mkdir("/foo") under MSW
Creating a directory with the leading path separator unexpectedly
created it under the current directory rather than in the root of the
current drive under MSW, due to the path being considered relative, in
spite of starting with the path separator, because it didn't have the
volume.

Fix this by avoiding the use of IsAbsolute() in Mkdir() and checking for
m_relative instead, as it seems the safest possible fix for this bug
because changing IsAbsolute() to return true in this case might change
the behaviour of the existing code.

Closes #4470.
2021-09-13 21:25:30 +01:00
Vadim Zeitlin
8db2f45171 Fix handling multiple leading backslashes in wxFileName under MSW
Extend the existing workaround to work not only with explicitly
wxPATH_DOS paths, but with paths implicitly using the DOS format due to
it being the default format for the current platform.

Closes #19261.
2021-09-13 20:53:27 +01:00
Vadim Zeitlin
a4940bf696 Extract wxLocaleSetter from the tests into a private header
This will allow using this class in the library code too.

No real changes yet, this is a pure refactoring.

This commit is best viewed using git --color-moved option.
2021-08-07 18:04:22 +02:00
Vadim Zeitlin
fa1f7e74ce Merge branch 'deprecate-filename-normalize'
Deprecate wxFilename::Normalize() without flags and add convenient
GetAbsolutePath() to be used instead.

See https://github.com/wxWidgets/wxWidgets/pull/2428
2021-07-17 17:10:40 +02:00
Vadim Zeitlin
9aae8fc81f Remove checks for LXC containers used under Travis CI only
As we don't use Travis CI any longer, we don't need these checks
neither.
2021-07-15 19:55:01 +02:00
Vadim Zeitlin
f37d449208 Add convenient wxFileName::GetAbsolutePath() wrapper and use it
This wrapper simply combines the calls to MakeAbsolute() and
GetFullPath(), but using it results in shorter and more clear code, so
it seems to be worth having.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
3539a81a8a Define a helper variable to reduce #ifdefs in wxFileName test
No real changes, just avoid repeating "#ifdef __WINDOWS__" multiple
times.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
702c221901 Deprecate wxPATH_NORM_ALL and Normalize() with default flags
Using wxFileName::Normalize() with default flags could be surprising and
result in bugs in the code, as shown by our own wrong use of it in
wxFileSystemWatcher corrected in the previous commit.

Deprecate using it without any flags and recommend using MakeAbsolute()
instead.

Also improve the related parts of the documentation.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
6d2af9e7a1 Use wxFileName::MakeAbsolute() instead of Normalize()
Make the code more clear by being more explicit about what it does.

No real changes and no changes in behaviour at all.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
071771474e Remove CppUnit boilerplate from wxFileName test
This is similar to the grand parent commit for the file functions.

No real changes.
2021-07-04 15:03:12 +01:00
Vadim Zeitlin
bc12930061 Merge branch 'filename-resolve-symlink'
Add wxFileName::ResolveLink().

See https://github.com/wxWidgets/wxWidgets/pull/2300
2021-04-07 12:38:37 +02:00
Vadim Zeitlin
1b30e64179 Fix spelling in an assert failure message
No real changes.
2021-04-07 01:45:32 +02:00
Vadim Zeitlin
c41357ed22 Skip another test using /proc and /sys when using LXC
This should have been part of the previous commit.
2021-04-04 15:35:46 +02:00
Ian McInerney
53bd1391f4 Add a new wxFileName function to resolve symlinks to absolute paths 2021-04-01 20:32:08 +01:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
Fabian Cenedese
a571a13d44 Fix bug in wxFileName::Normalize() with leading ".."
Don't discard initial ".." when there is more than one such component in
the beginning of the path.

Closes #18800.
2020-06-30 23:00:06 +02:00
Vadim Zeitlin
b714a3614b Update comments to remove mentions of 4KiB for /sys files
The actual size is the page size, so update the comments to match the
changes to the code in the previous commit.
2020-04-07 13:38:34 +02:00
Scott Talbert
b2b1b21bf2 Fix tests when run on ppc64le arch
Don't assume that files in /sys are 4KiB in size, their actual size is
equal to the kernel page size which varies depending on the architecture
and kernel build options.
2020-04-07 13:37:07 +02:00
Maarten Bent
2f78849d24 Fix build without precompiled headers 2018-11-26 23:51:40 +01:00
Maarten Bent
57180d68c8 Add wxOVERRIDE to test files
And cleanup some tailing spaces and tabs.
2018-07-29 12:08:53 +02:00
Vadim Zeitlin
a03ece4880 Remove st_blocks hack from wxFile::Length() under Linux
This reverts commit 41f6f17d01 ("return 0
(meaning the file is not seekable, as the docs now explain) instead of
4KB for the files in sysfs under Linux") as it seems to be wrong to
return a value different from what "ls -l" or "stat" return here and the
original problem was solved in a better way in the previous commit.

See #9965.

Closes #17818.
2017-12-15 18:46:22 +01:00
Dimitri Schoolwerth
3e945a0a5d Fix wxMSW test build in UTF-8 and ANSI build
Use wxString::t_str() with a function taking LPCTSTR (which is either
LPCWSTR or LPCSTR). And wxStrg::wc_str() for LPCOLESTR which,
ordinarily, is a wide string.
2017-06-22 02:04:50 +04:00
Vadim Zeitlin
ed09b7b6c0 Remove symlinks time comparison tests from wxFileName test
These tests don't seem to be sound, it's possible for one second or more to
pass between the two calls to GetTimes() and it's apparently possible for the
access time on the symlink to not change (due to /tmp being mounted with
"noatime" option perhaps?), resulting in Travis CI build failures.
2016-02-13 18:55:53 +01:00
Vadim Zeitlin
ef30f6fe63 Fix recently added wxFileName::MakeRelativeTo() unit test for non-Unix.
Don't hard code the use of slashes as path separators.
2015-05-30 03:38:03 +02:00
Vadim Zeitlin
fda09f917a Fix wxFileName::MakeRelativeTo() for directory relatively to itself.
The expected result in this case is ".", but the filename became empty instead
when wxPATH_NATIVE was used.

Fix this by examining GetFormat(format), which takes care of mapping
wxPATH_NATIVE to its real value, instead of wxPATH_NATIVE itself.

Also add a unit test verifying that this works as expected.

Closes #17010.
2015-05-29 16:23:17 +02:00
Dimitri Schoolwerth
8f8d58d193 Use wx-prefixed macros throughout the repository.
Change {DECLARE,IMPLEMENT}_*CLASS and {DECLARE,BEGIN,END}_EVENT_TABLE
occurrences to use the wx-prefixed version of the macros.
2015-04-23 22:00:35 +04:00
Vadim Zeitlin
614a0ef481 Don't change a shortcut file name when changing its path.
wxFileName::MakeRelativeTo() is only supposed to change the path of the file,
not its name, but it was doing the latter for the shortcuts as it implicitly
resolved them to the name of their target.

Fix this by ensuring we do not use wxPATH_NORM_SHORTCUT in MakeRelativeTo().

Closes #16239.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77509 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-08-29 23:22:05 +00:00
Vadim Zeitlin
f4b80e5337 Remove MSVC6 support.
Don't support this compiler any more, this allows to get rid of tons of
MSVC6-specific workarounds, in particular we can now use Bind() and natural
template functions calls in the library code.

Also remove MSVC6 project and solution files and don't generate them when
bakefile_gen is ran any more (removing the remaining occurrences of msvc6prj
from the bakefiles results in weird bake-time errors, so it's simpler to just
leave them there).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-05-15 22:32:17 +00:00
Vadim Zeitlin
747a681f61 Try to use /proc/self instead of /dev/core in the unit test.
/dev/core doesn't seem to exist on the machines running Travis CI builds,
check if /proc/self can work there.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75331 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-12-02 16:50:22 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
2d5efafe74 Disable test for setting the creation time under Unix.
Also document that this doesn't work there.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74424 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-06 19:14:20 +00:00
Vadim Zeitlin
55ab731681 Fix FILETIME <-> wxDateTime conversions while DST is in effect in wxMSW.
The result was (consistently, so the tests still passed) off by an hour when
the program was ran while DST was in effect. Fix this by avoiding the use of
FileTimeToLocalFileTime() and LocalFileTimeToFileTime() and just directly
converting FILETIME values to wxDateTime. Not only this is more correct but
it's also simpler and more efficient as well.

Also add a unit test for wxFileName::SetTimes() too.

Closes #13098.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74423 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-06 18:21:10 +00:00
Vadim Zeitlin
9ff99cb543 Fix filename test compilation with VC6.
Just disable tests resulting in an internal compiler error.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-11-10 12:21:46 +00:00
Jouk Jansen
67b09eacea Fix for specific filename syntax of OpenVMS
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72919 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-11-07 09:00:25 +00:00
Vadim Zeitlin
58263bb4c3 Make wxFILE_EXISTS_SYMLINK work on its own, without wxFILE_EXISTS_NO_FOLLOW.
Include the wxFILE_EXISTS_NO_FOLLOW bit in wxFILE_EXISTS_SYMLINK definition to
allow using just wxFileName::Exists(wxFILE_EXISTS_SYMLINK) which used to never
work because the link was followed.

Closes #14777.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-25 22:30:43 +00:00
Vadim Zeitlin
25db2c25bc Don't follow symlinks in wxFileName::Rmdir(wxPATH_RMDIR_RECURSIVE).
Following symlinks, possibly leading outside of the directory being removed,
is at best surprising and at worst dangerous, so don't do it and just mimic
the behaviour of "rm -rf", i.e. remove everything inside this directory,
including the symlinks themselves, but don't follow them.

Closes #14649.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-23 23:58:17 +00:00
Vadim Zeitlin
988f7eec77 Revert accidental incompatible change to wxFileName::DirExists().
The non-static version tests for the existence of the directory part of the
object only as is explicitly mentioned in the documentation, so do the test on
GetPath() and not GetFullPath() as we did since r72707.

Also add a unit test for this behaviour.

Closes #14771.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72718 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-22 15:51:26 +00:00
Vadim Zeitlin
4213fd51cc Fix tests compilation in STL build after r72707.
Add an explicit call to wxString::c_str() as there is no implicit conversion
in STL build.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72713 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-20 14:48:50 +00:00