summaryrefslogtreecommitdiff
path: root/gio/gfile.c
Commit message (Collapse)AuthorAgeFilesLines
* gfile: Make g_query_default_handler_async really AsyncMarco Trevisan (Treviño)2022-06-221-13/+35
| | | | | | | | Despite the name, the call was still doing blocking operations when looking for app handlers via GAppInfo. Now it's possible to use fully async calls. Together with previous commit, the API is now fully async.
* gfile: Use async API to get the default GAppInfo for typeMarco Trevisan (Treviño)2022-06-221-13/+45
| | | | | | | In both callbacks of g_file_query_default_handler_async() we were actually using I/O blocking APIs making it not fully async. Now that such API is provided, we can use it.
* gfile: Add Async API to create a temporary directory and return as GFileMarco Trevisan (Treviño)2022-06-221-0/+106
| | | | | | | While it's possible to create a directory synchronously via g_dir_make_tmp(), there's no such API that performs it asynchronously. So implement it using GFile, using a thread to perform such task.
* gfile: Add API to create a new temporary file asynchronouslyMarco Trevisan (Treviño)2022-06-221-0/+144
| | | | | Make possible to create a new gfile with a temporary name in async way, using the same API of g_file_new_tmp().
* gfile: Implement interface API to make symbolic links asynchronouslyMarco Trevisan (Treviño)2022-06-151-0/+128
| | | | | | | | | | The interface was ready for this API but it was not provided. So implement this, using a thread that calls the sync API for now. Add tests. Helps with: GNOME/glib#157
* gio: Add SPDX license headers automaticallyPhilip Withnall2022-05-181-0/+2
| | | | | | | | | | | | | | Add SPDX license (but not copyright) headers to all files which follow a certain pattern in their existing non-machine-readable header comment. This commit was entirely generated using the command: ``` git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs' ``` Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1415
* Fix non-initialized variable in gio/gfile.cLoic Le Page2022-03-311-1/+1
|
* docs: mark macros, flags, enums with percent signGabor Karsay2022-03-041-25/+25
|
* Merge branch 'feature/move_async' into 'main'Philip Withnall2022-02-071-4/+222
|\ | | | | | | | | Implement async file movement See merge request GNOME/glib!2469
| * Rename ambiguous structLucas Schwiderski2022-02-071-4/+4
| |
| * Implement async file movementLucas Schwiderski2022-02-071-0/+218
| |
* | gfile: resolve_relative_path isn't nullableZander Brown2022-02-021-3/+1
|/
* gio: fix GFile doc indentation and nullable annotationsMarc-André Lureau2021-10-251-220/+220
| | | | | | | Add missing (nullable), and use 2-space indentation to avoid markdown pre-formatted blocks when unwanted. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* gio: check the given child name is not an absolute pathMarc-André Lureau2021-10-251-0/+1
| | | | | | | | | | | | | As this would have undesirable consequence. Quoting Philip Withnall: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2305#note_1294729: The documentation never said anything about accepting absolute paths, so any code which is relying on that is relying on undocumented behaviour. We’re allowed to change that. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* gio: document g_file_get_relative_path() with absolute pathMarc-André Lureau2021-10-251-0/+3
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* gfileenumerator: Warn if name is not available for get_child()Philip Withnall2021-10-211-1/+3
| | | | | | | | | | | | `standard::name` must be available for `g_file_enumerator_get_child()` to work. Emit a critical warning and return if it’s not. This is similar to the existing behaviour in `g_file_enumerator_iterate()`. Improve the documentation to mention this. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2507
* The ETag returned by various GFile functions is nullableSebastian Dröge2021-02-171-5/+5
| | | | | | This was correctly annotated for proper return values but in case of out parameters it was only annotated as (optional) and not additionally as (nullable).
* gio: Use g_memdup2() instead of g_memdup() in obvious placesPhilip Withnall2021-02-041-3/+3
| | | | | | | | | | | | | Convert all the call sites which use `g_memdup()`’s length argument trivially (for example, by passing a `sizeof()`), so that they use `g_memdup2()` instead. In almost all of these cases the use of `g_memdup()` would not have caused problems, but it will soon be deprecated, so best port away from it. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #2319
* gio: Add explicit virtual g-i annotations for undiscovered invoker relationshipricotz/for-masterRico Tzschichholz2021-01-301-3/+3
|
* gfile: Add Linux kernel headers compatibility kludgeOle André Vadla Ravnås2021-01-191-15/+20
| | | | | | So we can still run at full speed on modern kernels in cases where an old toolchain was used to build GLib. This is often done deliberately to allow shipping binaries that need to run on a wide range of systems.
* Add nullable annotation for g_file_get_uri_schemeSophie Herold2021-01-061-4/+8
|
* gfile: Clarify refcount handling for g_file_replace_contents_bytes_async()Philip Withnall2020-10-141-1/+1
| | | | | | | | | | | This introduces no functional changes, but makes the refcount handling a little easier to follow by no longer splitting a ref/unref pair across three callbacks. Now, the ref/unref pairs are all within function-local scopes. Coverity CID: #1430783 Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* gio: Expose g_file_build_attribute_list_for_copyMaxim Mikityanskiy2020-10-061-45/+68
| | | | | | | | | | | | | | Expose a function that prepares an attribute query string to be passed to g_file_query_info() to get a list of attributes normally copied with the file. This function is used by the implementation of g_file_copy_attributes, and it's useful if one needs to split g_file_copy_attributes into two stages, for example, when nautilus does a recursive move of a directory. When files are moved from the source directory, its modification time changes. To preserve the mtime on the destination directory, it has to be queried before moving files and set after doing it, hence these two stages. Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
* gfile: Document TOCTTOU avoidance using g_file_delete()Philip Withnall2020-08-121-0/+15
| | | | | | | Don’t call `g_file_query_exists()` followed by `g_file_delete()`. Just call `g_file_delete()` and check the error. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* gfile: Add support for x-gvfs-notrash option to ignore mountsOndrej Holy2020-08-051-1/+3
| | | | | | | | | Add support for x-gvfs-notrash mount option, which allows to disable trash functionality for certain mounts. This might be especially useful e.g. to prevent trash folder creation on enterprise shares, which are also accessed from Windows... https://bugzilla.redhat.com/show_bug.cgi?id=1096200
* gfile: Fallback to fast-content-type if content-type is not setOndrej Holy2020-04-071-2/+8
| | | | | | | | | | | The G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE attribute doesn't have to be always set. See https://gitlab.gnome.org/GNOME/gvfs/-/merge_requests/68 for more details. In that case, the g_file_query_default_handler function fails with the "No application is registered as handling this file" error. Let's fallback to the "standard::fast-content-type" attribute instead to fix issues when opening such files. https://gitlab.gnome.org/GNOME/nautilus/-/issues/1425
* gfile: Fix g_file_peek_path() for remote locationsOndrej Holy2020-02-031-1/+4
| | | | | | g_file_peek_path() doesn't work for GVfs locations on the first attempt, because the compare-and-swap loop is broken before the return value is set.
* gfile: Do not return target-uri from g_file_peek_path()Ondrej Holy2020-02-031-36/+1
| | | | | | | | | | | | | | | | | | Documentation says that g_file_peek_path() returns exactly the same what g_file_get_path(), but this is not true. Apart from that the code segfaults for some uris (e.g. for "trash:///"), it returns target-uri for trash and recent schemes. This is unexpected and can lead to various issues among others because the target-uri paths are not automatically translated back to GDaemonFile as it is done with gvfsd-fuse paths. g_file_get_path() returns NULL for trash and recent schemes, because fuse paths are not provided for those schemes. So g_file_peek_path() should return NULL as well. It is up to the concrete application to use target-uri when appropriate. This change was made as a part of commit 4808a957, however, neither the commit message, neither the corresponding bug doesn't mention this crucial change and doesn't give any clear reasoning. So let's revert this.
* Merge branch 'wip/oholy/gfile-docs' into 'master'Philip Withnall2020-01-311-5/+1
|\ | | | | | | | | | | | | Symlink-related fixes for `g_file_move()` Closes #986 See merge request GNOME/glib!900
| * gfile: Do not follow symlinks when movingOndrej Holy2019-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | It is expected that `g_file_move()` moves symlink file itself, not its target. Unfortunately, copy and delete fallback passes `GFileCopyFlags` and don't explicitly use `G_FILE_COPY_NOFOLLOW_SYMLINKS`. This may cause that symlink target is copied and symlink itself is removed. Let's explicitly pass `G_FILE_COPY_NOFOLLOW_SYMLINKS` to the copy operation to prevent this unexpected behavior. https://gitlab.gnome.org/GNOME/glib/issues/986
| * gfile: Remove `G_FILE_COPY_NOFOLLOW_SYMLINKS` from `g_file_move()` docsOndrej Holy2019-06-071-4/+0
| | | | | | | | | | | | | | | | | | The `G_FILE_COPY_NOFOLLOW_SYMLINKS` flag doesn't make sense for move operation, neither local implementation doesn't handle this flag in any way. Therefore this paragraph should be removed from the docs (it was probably copy&pasted from `g_file_copy()` docs by mistake). Closes: https://gitlab.gnome.org/GNOME/glib/issues/986
* | Merge branch 'patch-1' into 'master'Simon McVittie2019-10-061-1/+1
|\ \ | | | | | | | | | | | | gio/gfile: fix parameter reference for value_p See merge request GNOME/glib!1149
| * | gio/gfile: fix parameter reference for value_pDavid Lechner2019-10-061-1/+1
| | | | | | | | | This fixes a parameter reference to @value_p in g_file_set_attribute()
* | | Merge branch 'patch-2' into 'master'Simon McVittie2019-10-061-4/+4
|\ \ \ | | | | | | | | | | | | | | | | gio/gfile: fix parameter references to @contents See merge request GNOME/glib!1150
| * | | gio/gfile: fix parameter references to @contentsDavid Lechner2019-10-061-4/+4
| |/ / | | | | | | Fix a number of occurrences where the parameter reference was missing the trailing 's'
* | | gio/gfile: fix typo in doc commentDavid Lechner2019-10-061-1/+1
|/ / | | | | This fixes a typo in g_file_has_prefix() do comments.
* | gfile: Use a more specific error message if symlinks are not supportedPhilip Withnall2019-09-301-1/+1
| | | | | | | | | | | | | | The string is already translated in `GLocalFile`, so this doesn’t introduce a new translatable string. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* | gfile: Don’t copy files as private if using default permissionsPhilip Withnall2019-09-301-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | If a copy operation is started with `G_FILE_COPY_TARGET_DEFAULT_PERMS`, don’t create the destination file as private. Instead, create it with the process’ current umask (i.e. ‘default permissions’). This is a partial re-work of commit d8f8f4d637ce43f8699ba94c9b, with input from Ondrej Holy. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #174
* | gfile: Factor out flags when copying filesPhilip Withnall2019-09-301-6/+9
| | | | | | | | | | | | | | This introduces no functional changes; just reduces duplication in the code a little. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* | minor typos in the documentation (a/an)Дилян Палаузов2019-08-241-1/+1
| |
* | Fixing find_enclosing_mount() documentationEmmanuel Fleury2019-07-011-3/+3
|/ | | | Fix issue #453
* gfile: Limit access to files when copyingOndrej Holy2019-05-241-5/+6
| | | | | | | | file_copy_fallback creates new files with default permissions and set the correct permissions after the operation is finished. This might cause that the files can be accessible by more users during the operation than expected. Use G_FILE_CREATE_PRIVATE for the new files to limit access to those files.
* gfile: Fix documentation links to non-existent symbolsPhilip Withnall2019-03-151-1/+1
| | | | | | | I presume this documentation was written before those APIs were renamed during code review. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* gfile: Add some missing parameter documentationPhilip Withnall2019-03-151-0/+1
| | | | Signed-off-by: Philip Withnall <withnall@endlessm.com>
* gappinfo: Add launch_uris_async() and launch_uris_finish() vfuncsOndrej Holy2019-01-281-1/+1
| | | | | | | | | | | | The g_app_info_launch_uris_async() and g_app_info_launch_uris_finish() functions are crucial to fix g_app_info_launch_default_for_uri_async() to be really asynchronous. This patch also adds GDesktopAppInfo implementation of that vfuncs. The implementation may still use some synchronous calls to local MIME DB. https://gitlab.gnome.org/GNOME/glib/issues/1347 https://gitlab.gnome.org/GNOME/glib/issues/1249
* gfile: Add g_file_query_default_handler_async()Ondrej Holy2019-01-281-0/+123
| | | | | | | | | | | | | This is needed as a first step to fix the g_app_info_launch_default_for_uri_async() function to be really asynchronous. It still uses the g_app_info_get_default_for_uri_scheme() and g_app_info_get_default_for_type() functions, which may use synchronous calls to local MIME DB. https://gitlab.gnome.org/GNOME/glib/issues/1347 https://gitlab.gnome.org/GNOME/glib/issues/1249
* gfile: Fix leak in g_file_query_default_handler()Ondrej Holy2019-01-281-0/+2
| | | | | Add missing `g_free (uri_scheme)` to fix leak when `uri_scheme[0]` is equal to `\0`.
* gfile: Document usefulness of g_file_dup()Philip Withnall2018-06-191-0/+5
| | | | | | Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/glib/issues/807
* gio: PPC64 returns EOPNOTSUPP from splice() if not supportedwip/hughsie/EOPNOTSUPPRichard Hughes2018-06-141-1/+1
|
* gio: Fix a typo in the docs for g_file_is_native()Matthew Leeds2018-05-041-1/+1
|