summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.cc
Commit message (Collapse)AuthorAgeFilesLines
* Fix: Linux file:// listings are sorted but not fully internationalizedyuzo@chromium.org2009-07-151-12/+67
| | | | | | | | | | | | | | | | | Changed the code such that file names are converted to UTF-16 before comparison. Ideally, the locale should be considered, but my conclusion is that ignoring it is a reasonable tradeoff. Passing a locale-aware comparator (collator) from src/chrome(or src/app?) to src/base requires too much effort, in my opinion. BUG=16179 TEST=Open a file:// URL for a directory that contains non-ascii-named files. Observe that files are sorted properly in the list, in a case-sensitive manner. Review URL: http://codereview.chromium.org/149449 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20706 0039d316-1c4b-4281-b951-d872f2087c98
* Order posix file listings by type as well as name.estade@chromium.org2009-06-241-4/+25
| | | | | | | | | http://crbug.com/12812 TEST=go to /, see that directories are sorted before other files. Review URL: http://codereview.chromium.org/147063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19100 0039d316-1c4b-4281-b951-d872f2087c98
* Linux: refactor zygote supportagl@chromium.org2009-06-121-14/+2
| | | | | | | | | | | | | | | | | | | http://code.google.com/p/chromium/wiki/LinuxZygote * Move Chrome specific bits out of base * Move away from the idea of reserved file descriptors (which don't really work with zygotes) * Load resources before forking renderers (means that we don't need communication between the zygote process and the renderers) * Make sure that gdb works against the browser again * Make sure that we have different ASLR between the renderers and the browser. http://codereview.chromium.org/119335 (This is a reland. First landed in r18109, reverted in r18112.) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18291 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 18109, 18111: Windows UI tests failed.agl@chromium.org2009-06-101-2/+14
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18112 0039d316-1c4b-4281-b951-d872f2087c98
* Linux: refactor zygote supportagl@chromium.org2009-06-101-14/+2
| | | | | | | | | | | | | | | | | | http://code.google.com/p/chromium/wiki/LinuxZygote * Move Chrome specific bits out of base * Move away from the idea of reserved file descriptors (which don't really work with zygotes) * Load resources before forking renderers (means that we don't need communication between the zygote process and the renderers) * Make sure that gdb works against the browser again * Make sure that we have different ASLR between the renderers and the browser. http://codereview.chromium.org/119335 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18109 0039d316-1c4b-4281-b951-d872f2087c98
* Include a parent directory link in the file list for file:///somepathyuzo@chromium.org2009-06-091-2/+22
| | | | | | | | | | | | | | | Also, order files/directories lexicographically. TEST=on linux, type file:///usr/ in the address bar and make sure the contents are sorted and include an entry for '..', which is [parent directory]. On windows, type file:///C:/Users/ . BUG=12621, 12812 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17933 0039d316-1c4b-4281-b951-d872f2087c98
* Enable zygote manager by default.dkegel@google.com2009-06-081-1/+1
| | | | | | | | | | | | | | Fix broken recursion check. Make OpenFile warning less scary, indicate it's normal at start of ui tests. Make ui tests pass. Avoid generating extra code on Mac. BUG=11841 TEST=start the browser, then make chrome and all .pak files unreadable; or alternately, start an installed browser, and uninstall the browser while it's running. Then create a new tab and browse to two new sites. Review URL: http://codereview.chromium.org/119289 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17909 0039d316-1c4b-4281-b951-d872f2087c98
* Prototype implementation of zygotes. dkegel@google.com2009-06-061-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Limitations that need addressing still: - Doesn't forcibly terminate children that should have exited but haven't Enable with env var ENABLE_ZYGOTE_MANAGER=1. BUG=11841 TEST= start the browser, then make chrome and all .pak files unreadable; or alternately, start an installed browser, and uninstall the browser while it's running. Then create a new tab and browse to two new sites. Here's an example script to hide and unhide the .pak files (note: do not move the directory they're in, that doesn't work): #!/bin/sh chmod_all() { chmod $1 sconsbuild/Debug/chrome for path in . locales obj/chrome/app/intermediate/repack obj/global_intermediate/* themes do chmod $1 sconsbuild/Debug/$path/*.pak done } case $1 in hide) chmod_all 000 ;; show) chmod_all 755 ;; esac Review URL: http://codereview.chromium.org/115773 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17840 0039d316-1c4b-4281-b951-d872f2087c98
* Add file_util::ReplaceFile and use it in ImportantFileWriter.phajdan.jr@chromium.org2009-05-191-0/+4
| | | | | | | | | | It has more strict semantics than file_util::Move. http://crbug.com/11585 Review URL: http://codereview.chromium.org/113207 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16386 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Add file_util::ReplaceFile and use it in ImportantFileWriter."phajdan.jr@chromium.org2009-05-181-4/+0
| | | | | | | | | | http://crbug.com/11585 TBR=stoyan Review URL: http://codereview.chromium.org/113534 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16296 0039d316-1c4b-4281-b951-d872f2087c98
* Add file_util::ReplaceFile and use it in ImportantFileWriter.phajdan.jr@chromium.org2009-05-181-0/+4
| | | | | | | | | | It has more strict semantics than file_util::Move. http://crbug.com/11585 Review URL: http://codereview.chromium.org/113207 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16291 0039d316-1c4b-4281-b951-d872f2087c98
* Add support for almost-recursive watches in Linux DirectoryWatcherphajdan.jr@chromium.org2009-05-141-0/+10
| | | | | | | | | | | | | | | | | After this patch DirectoryWatcher when asked for recursive watch will scan the subtree and add inotify watches for each subfolder, but further changes to the tree structure won't trigger adding/removing watches. Support for really recursive watches is planned. This is just to divide the work, because the task is not easy. Based on patch by Janwar Dinata <j.dinata@gmail.com> reviewed at http://codereview.chromium.org/92151 http://crbug.com/8968 Review URL: http://codereview.chromium.org/115229 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16070 0039d316-1c4b-4281-b951-d872f2087c98
* posix: directories should only be readable by the user.evan@chromium.org2009-05-121-3/+2
| | | | | | | | | | | | | Almost all the data we store is private, so we shouldn't even allow it to be group-readable. Note that files still obey the user's umask and if someone wants to make their download directory world-readable we won't undo that. BUG=11776 Review URL: http://codereview.chromium.org/113287 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15890 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: Add a macro for handling EINTR.agl@chromium.org2009-05-011-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On POSIX systems, system calls can be interrupted by signals. In this case, they'll return EINTR, indicating that the system call needs to be restarted. (The situation is a little more complicated than this with SA_RESTART, but you can read man 7 signal if you like.) The short of it is that you need to catch EINTR and restart the call for these system calls: * read, readv, write, writev, ioctl * open() when dealing with a fifo * wait* * Anything socket based (send*, recv*, connect, accept etc) * flock and lock control with fcntl * mq_ functions which can block * futex * sem_wait (and timed wait) * pause, sigsuspend, sigtimedwait, sigwaitinfo * poll, epoll_wait, select and 'p' versions of the same * msgrcv, msgsnd, semop, semtimedop * close (although, on Linux, EINTR won't happen here) * any sleep functions (careful, you need to handle this are restart with different arguments) We've been a little sloppy with this until now. This patch adds a macro for dealing with this and corrects every case of these system calls (that I found). The macro is HANDLE_EINTR in base/eintr_wrapper.h. It's safe to include on Windows and is a no-op there. On POSIX, it uses GCC magic to return the correct type based on the expression and restarts the system call if it throws EINTR. And you can use it like: HANDLE_EINTR(close(fd)); Or: ssize_t bytes_read = HANDLE_EINTR(read(fd, buffer, len)); *BEWARE* that it will evaluate the argument multiple times, so this is not safe: HANDLE_EINTR(close(FireMissiles())); http://groups.google.com/group/chromium-dev/browse_thread/thread/41a35b2a457d73a0 http://codereview.chromium.org/100225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15102 0039d316-1c4b-4281-b951-d872f2087c98
* ImportantFileWriterphajdan.jr@chromium.org2009-04-281-16/+6
| | | | | | | | | | | | | | Introducing a class for writing important files, preventing their corruption during writing. Switched PrefService to use it. Other classes will be switched in future changesets. TEST=This may affect things using preferences. Make sure that changes in preferences don't get lost, and that you don't get excessive disk activity when changing preferences. http://crbug.com/10618 Review URL: http://codereview.chromium.org/83001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14717 0039d316-1c4b-4281-b951-d872f2087c98
* Only check errno when it can be set.phajdan.jr@chromium.org2009-04-271-1/+1
| | | | | | | | This is a follow-up after http://codereview.chromium.org/77022 Review URL: http://codereview.chromium.org/99055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14602 0039d316-1c4b-4281-b951-d872f2087c98
* Submitting http://codereview.chromium.org/87039 on behalf of hamaji.erikkay@google.com2009-04-231-1/+17
| | | | | | Review URL: http://codereview.chromium.org/92053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14304 0039d316-1c4b-4281-b951-d872f2087c98
* Protect RandUint64 against EINTR.phajdan.jr@chromium.org2009-04-231-0/+12
| | | | | | Review URL: http://codereview.chromium.org/77022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14297 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 14152.thestig@chromium.org2009-04-211-2/+3
| | | | | | | TBR=tony Review URL: http://codereview.chromium.org/87066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14154 0039d316-1c4b-4281-b951-d872f2087c98
* Stop using and remove deprecated file_util::TrimTrailingSeparator().thestig@chromium.org2009-04-211-3/+2
| | | | | | Review URL: http://codereview.chromium.org/67271 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14152 0039d316-1c4b-4281-b951-d872f2087c98
* Implement file_util::CountFilesCreatedAfter() for posix environments.evan@chromium.org2009-04-211-0/+30
| | | | | | | | | BUG=9833 Review URL: http://codereview.chromium.org/87003 Patch from Shinichiro Hamaji <hamaji@google.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14081 0039d316-1c4b-4281-b951-d872f2087c98
* Use "org.chromium" in place of "com.google.chrome" in posix temporary file ↵estade@chromium.org2009-03-171-0/+4
| | | | | | | | names for non-chrome builds. Review URL: http://codereview.chromium.org/46087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11897 0039d316-1c4b-4281-b951-d872f2087c98
* Implement DownloadFile::Rename() for posix. Downloads work on linux!estade@chromium.org2009-03-131-2/+8
| | | | | | Review URL: http://codereview.chromium.org/46020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11659 0039d316-1c4b-4281-b951-d872f2087c98
* Cleanup in {test_,}file_util_posix.ccphajdan.jr@chromium.org2009-03-061-3/+6
| | | | | | | | | | - DCHECK_EQ instead of DCHECK(foo == bar) - more detailed log error messages - add a comment why we use 0777 permissions for new dirs (umask should produce sane permissions) Review URL: http://codereview.chromium.org/40162 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11105 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 11102.phajdan.jr@chromium.org2009-03-061-6/+3
| | | | | | | | | | Used git svn dcommit instead of git cl dcommit by mistake. Reverting to re-commit properly. TBR=erikkay Review URL: http://codereview.chromium.org/40213 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11104 0039d316-1c4b-4281-b951-d872f2087c98
* first cutphajdan.jr@chromium.org2009-03-061-3/+6
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11102 0039d316-1c4b-4281-b951-d872f2087c98
* Properly honor base::SharedMemory semantics for name="" to meanjrg@chromium.org2009-02-041-14/+48
| | | | | | | | | | | | new/private shared memory on POSIX. Transition base::SharedMemory implementation to file/mmap() to prevent leaking of wired kernel resources and allow easier cleanup. Enable one more shared_memory unit test for POSIX. Enable stats_table_unittest.cc for Mac, and modify it so it cleans up. Review URL: http://codereview.chromium.org/19724 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9114 0039d316-1c4b-4281-b951-d872f2087c98
* Safe browsing cleanup:estade@chromium.org2009-01-281-4/+4
| | | | | | | | | * wstring -> FilePath * create versions of WriteFile/ReadFile with FilePath signatures Review URL: http://codereview.chromium.org/19610 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8797 0039d316-1c4b-4281-b951-d872f2087c98
* Fix TODOs in base/ :phajdan.jr@chromium.org2009-01-131-6/+9
| | | | | | | | | | - switch to FilePath inside CopyDirectory - be less racy in ProcessUtilTest.KillSlowChild Review URL: http://codereview.chromium.org/17013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7948 0039d316-1c4b-4281-b951-d872f2087c98
* Try to consistently use arraysize() with strlcpy().deanm@chromium.org2009-01-021-1/+1
| | | | | | | | | For a char*, sizeof() == arraysize(), so there is nothing wrong with the current code. However I think it's important to be clear that the lcpy() functions work in characters and not bytes. The danger would be accidently using sizeof() with wcslcpy, for example copying some code as an example or modifying old code to use a wchar instead of a char. Review URL: http://codereview.chromium.org/17019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7536 0039d316-1c4b-4281-b951-d872f2087c98
* file_util minor cleanup:erikkay@google.com2008-12-231-5/+25
| | | | | | | | | | * add POSIX version of IsPathWritable * convert IsPathWritable to FilePath * convert CreateNewTempDirectory to FilePath * fix a bug where recursive delete errors weren't being handled in POSIX Review URL: http://codereview.chromium.org/16241 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7430 0039d316-1c4b-4281-b951-d872f2087c98
* revert r6938estade@chromium.org2008-12-121-0/+40
| | | | | | | (i.e. reapply 6935, with fix) Review URL: http://codereview.chromium.org/14087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6953 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 6935.ojan@google.com2008-12-121-40/+0
| | | | | | | Broke compile Review URL: http://codereview.chromium.org/14083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6938 0039d316-1c4b-4281-b951-d872f2087c98
* Implement the memory mapped file class for posix.estade@chromium.org2008-12-121-0/+40
| | | | | | Review URL: http://codereview.chromium.org/14073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6935 0039d316-1c4b-4281-b951-d872f2087c98
* Move file enumeration to filepaths.avi@google.com2008-12-111-12/+12
| | | | | | Review URL: http://codereview.chromium.org/13315 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6784 0039d316-1c4b-4281-b951-d872f2087c98
* Port directory lister to allow the linux and mac test shells to display file ↵estade@chromium.org2008-11-201-19/+29
| | | | | | | | | | directories. This is a revision of r5725. It doesn't break mac build. Review URL: http://codereview.chromium.org/11507 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5792 0039d316-1c4b-4281-b951-d872f2087c98
* revert 5730estade@chromium.org2008-11-191-29/+19
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5731 0039d316-1c4b-4281-b951-d872f2087c98
* Port directory lister to posix.estade@chromium.org2008-11-191-19/+29
| | | | | | | | Fix of issue 11437. Review URL: http://codereview.chromium.org/11293 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5730 0039d316-1c4b-4281-b951-d872f2087c98
* revert 5725estade@chromium.org2008-11-191-29/+19
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5727 0039d316-1c4b-4281-b951-d872f2087c98
* Port directory lister so test shell can view file directories.estade@chromium.org2008-11-191-19/+29
| | | | | | Review URL: http://codereview.chromium.org/11437 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5725 0039d316-1c4b-4281-b951-d872f2087c98
* Implement some missing file util functions.estade@chromium.org2008-11-171-10/+10
| | | | | | Review URL: http://codereview.chromium.org/11208 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5571 0039d316-1c4b-4281-b951-d872f2087c98
* Added CreateTemporaryFileName that takes a FilePath argument.estade@chromium.org2008-11-111-11/+12
| | | | | | Review URL: http://codereview.chromium.org/9752 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5142 0039d316-1c4b-4281-b951-d872f2087c98
* Port more of url_request_unittest.cc.dkegel@google.com2008-11-041-2/+2
| | | | | | | | Also do a little bit of the FilePath rewrite as it pertains to this test. Review URL: http://codereview.chromium.org/9074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4652 0039d316-1c4b-4281-b951-d872f2087c98
* Begin the first small step towards using FilePath everywhere:evanm@google.com2008-10-301-41/+47
| | | | | | | | | | - Add some transition APIs. - Start migrating some code to transition APIs. Review URL: http://codereview.chromium.org/8825 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4254 0039d316-1c4b-4281-b951-d872f2087c98
* This CL adds prompting for dangerous types of files (executable) when they ↵jcampan@chromium.org2008-10-101-0/+7
| | | | | | | | | | | | | | | | are automatically downloaded. The file is saved with a temporary name (dangerous_download_xxxx.download) in the download directory and the user is presented (in the download shelf and the download tab if opened) with a warning message and buttons to save/discard the download. If discarded the download is removed (and its file deleted). If saved, download goes as usual. Dangerous downloads not confirmed by the user are deleted on shutdown. TEST=Download a small exe file, try using the save/discard button from the download shelf and from the download tab (the intent is that the file has been entirely downloaded by the time you take action). Try again with a slow/big download (that time the download is expected not to be finished when approved/discarded). Review URL: http://codereview.chromium.org/6043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3228 0039d316-1c4b-4281-b951-d872f2087c98
* Cross-platform wrappers for fopen, _wfopen_s, etc.mark@chromium.org2008-10-011-0/+9
| | | | | | | | | Patch by Paweł Hajdan jr <phajdan.jr@gmail.com>. http://codereview.chromium.org/6005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2760 0039d316-1c4b-4281-b951-d872f2087c98
* Add file_util::GetFileInfo as a means to provide more information about a filedarin@google.com2008-09-261-2/+3
| | | | | | | | | | | path. This CL changes GetFileSize to be implemented in terms of GetFileInfo since under the hood on all platforms the same system call is used. R=mark Review URL: http://codereview.chromium.org/4286 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2624 0039d316-1c4b-4281-b951-d872f2087c98
* Implement CopyDirectory() for the POSIX branch of file_util.evanm@google.com2008-09-181-4/+105
| | | | | | | This lets us pass some more base unit tests and at least one net test. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2372 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX/Linux related changes to file_util:mark@chromium.org2008-09-111-16/+31
| | | | | | | | | | | | | | - Replaced mktemp with mkstemp - Implemented file_util::CopyFile for Linux, run FileUtilTest on Linux - Cleaned up some invalid uses of c_str() on a temporary std::string - Changed file_util::WriteFile to allow for partial writes Patch by Matthias Reitinger <reimarvin@gmail.com> http://codereview.chromium.org/1869 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2070 0039d316-1c4b-4281-b951-d872f2087c98
* CreateDirectory() should check if an existing path is actually a directory ↵mmoss@google.com2008-09-111-3/+8
| | | | | | | | before skipping it. Also update a couple instances and comments to reflect current behaviour (see also http://codereview.chromium.org/1681). Review URL: http://codereview.chromium.org/1709 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2060 0039d316-1c4b-4281-b951-d872f2087c98