1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gnome-vfs-ops.c - Synchronous operations for the GNOME Virtual File
System.
Copyright (C) 1999 Free Software Foundation
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Ettore Perazzoli <ettore@gnu.org> */
#include <config.h>
#include "gnome-vfs-ops.h"
#include "gnome-vfs-monitor-private.h"
#include "gnome-vfs-cancellable-ops.h"
#include "gnome-vfs-handle-private.h"
#include "gnome-vfs-private-utils.h"
#include <glib.h>
/**
* gnome_vfs_open:
* @handle: pointer to a pointer to a #GnomeVFSHandle object.
* @text_uri: string representing the uri to open.
* @open_mode: open mode.
*
* Open @text_uri according to mode @open_mode. On return, @handle will then
* contain a pointer to a handle for the open file.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_open (GnomeVFSHandle **handle,
const gchar *text_uri,
GnomeVFSOpenMode open_mode)
{
GnomeVFSURI *uri;
GnomeVFSResult result;
g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
*handle = NULL;
g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
result = gnome_vfs_open_uri (handle, uri, open_mode);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_open_uri:
* @handle: pointer to a pointer to a #GnomeVFSHandle object.
* @uri: uri to open.
* @open_mode: open mode.
*
* Open @uri according to mode @open_mode. On return, @handle will then
* contain a pointer to a handle for the open file.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_open_uri (GnomeVFSHandle **handle,
GnomeVFSURI *uri,
GnomeVFSOpenMode open_mode)
{
return gnome_vfs_open_uri_cancellable (handle, uri, open_mode, NULL);
}
/**
* gnome_vfs_create:
* @handle: pointer to a pointer to a #GnomeVFSHandle object.
* @text_uri: string representing the uri to create.
* @open_mode: mode to leave the file opened in after creation (or %GNOME_VFS_OPEN_MODE_NONE
* to leave the file closed after creation).
* @exclusive: whether the file should be created in "exclusive" mode.
* i.e. if this flag is nonzero, operation will fail if a file with the
* same name already exists.
* @perm: bitmap representing the permissions for the newly created file
* (Unix style).
*
* Create @text_uri according to mode @open_mode. On return, @handle will then
* contain a pointer to a handle for the open file.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_create (GnomeVFSHandle **handle,
const gchar *text_uri,
GnomeVFSOpenMode open_mode,
gboolean exclusive,
guint perm)
{
GnomeVFSURI *uri;
GnomeVFSResult result;
g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
*handle = NULL;
g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
result = gnome_vfs_create_uri (handle, uri, open_mode, exclusive, perm);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_forget_cache:
* @handle: handle of the file to affect.
* @offset: start point of the region to be freed.
* @size: length of the region to be freed (or until the end of the
* file if 0 is specified).
*
* With this call you can announce to gnome-vfs that you will no longer
* use the region of data starting at @offset with the size of @size. Any
* cached data for this region might then be freed.
*
* This might be useful if you stream large files, for example.
*
* Return value: an integer representing the result of the operation.
*
* Since: 2.12
*/
GnomeVFSResult
gnome_vfs_forget_cache (GnomeVFSHandle *handle,
GnomeVFSFileOffset offset,
GnomeVFSFileSize size)
{
g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
return _gnome_vfs_handle_forget_cache (handle, offset, size);
}
/**
* gnome_vfs_create_uri:
* @handle: pointer to a pointer to a #GnomeVFSHandle object.
* @uri: uri for the file to create.
* @open_mode: open mode.
* @exclusive: whether the file should be created in "exclusive" mode.
* i.e. if this flag is nonzero, operation will fail if a file with the
* same name already exists.
* @perm: bitmap representing the permissions for the newly created file
* (Unix style).
*
* Create @uri according to mode @open_mode. On return, @handle will then
* contain a pointer to a handle for the open file.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_create_uri (GnomeVFSHandle **handle,
GnomeVFSURI *uri,
GnomeVFSOpenMode open_mode,
gboolean exclusive,
guint perm)
{
return gnome_vfs_create_uri_cancellable (handle, uri, open_mode,
exclusive, perm, NULL);
}
/**
* gnome_vfs_close:
* @handle: pointer to a #GnomeVFSHandle object.
*
* Close file associated with @handle.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_close (GnomeVFSHandle *handle)
{
return gnome_vfs_close_cancellable (handle, NULL);
}
/**
* gnome_vfs_read:
* @handle: handle of the file to read data from.
* @buffer: pointer to a buffer that must be at least @bytes bytes large.
* @bytes: number of bytes to read.
* @bytes_read: pointer to a variable that will hold the number of bytes
* effectively read on return.
*
* Read @bytes from @handle. As with Unix system calls, the number of
* bytes read can effectively be less than @bytes on return and will be
* stored in @bytes_read.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_read (GnomeVFSHandle *handle,
gpointer buffer,
GnomeVFSFileSize bytes,
GnomeVFSFileSize *bytes_read)
{
return gnome_vfs_read_cancellable (handle, buffer, bytes, bytes_read,
NULL);
}
/**
* gnome_vfs_write:
* @handle: handle of the file to write data to.
* @buffer: pointer to the buffer containing the data to be written.
* @bytes: number of bytes to write.
* @bytes_written: pointer to a variable that will hold the number of bytes
* effectively written on return.
*
* Write @bytes into the file opened through @handle. As with Unix system
* calls, the number of bytes written can effectively be less than @bytes on
* return and will be stored in @bytes_written.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_write (GnomeVFSHandle *handle,
gconstpointer buffer,
GnomeVFSFileSize bytes,
GnomeVFSFileSize *bytes_written)
{
return gnome_vfs_write_cancellable (handle, buffer, bytes,
bytes_written, NULL);
}
/**
* gnome_vfs_seek:
* @handle: handle for which the current position must be changed.
* @whence: integer value representing the starting position.
* @offset: number of bytes to skip from the position specified by @whence.
* (a positive value means to move forward; a negative one to move backwards).
*
* Set the current position for reading/writing through @handle.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_seek (GnomeVFSHandle *handle,
GnomeVFSSeekPosition whence,
GnomeVFSFileOffset offset)
{
return gnome_vfs_seek_cancellable (handle, whence, offset, NULL);
}
/**
* gnome_vfs_tell:
* @handle: handle for which the current position must be retrieved.
* @offset_return: pointer to a variable that will contain the current position
* on return.
*
* Return the current position on @handle. This is the point in the file
* pointed to by handle that reads and writes will occur on.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_tell (GnomeVFSHandle *handle,
GnomeVFSFileSize *offset_return)
{
g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
return _gnome_vfs_handle_do_tell (handle, offset_return);
}
/**
* gnome_vfs_get_file_info:
* @text_uri: uri of the file for which information will be retrieved.
* @info: pointer to a #GnomeVFSFileInfo object that will hold the information
* for the file on return.
* @options: options for retrieving file information.
*
* Retrieve information about @text_uri. The information will be stored in
* @info.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_get_file_info (const gchar *text_uri,
GnomeVFSFileInfo *info,
GnomeVFSFileInfoOptions options)
{
GnomeVFSURI *uri;
GnomeVFSResult result;
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_NOT_SUPPORTED;
result = gnome_vfs_get_file_info_uri(uri, info, options);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_get_file_info_uri:
* @uri: uri of the file for which information will be retrieved.
* @info: pointer to a #GnomeVFSFileInfo object that will hold the information
* for the file on return.
* @options: options for retrieving file information.
*
* Retrieve information about @text_uri. The information will be stored in
* @info.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_get_file_info_uri (GnomeVFSURI *uri,
GnomeVFSFileInfo *info,
GnomeVFSFileInfoOptions options)
{
return gnome_vfs_get_file_info_uri_cancellable (uri,
info,
options,
NULL);
}
/**
* gnome_vfs_get_file_info_from_handle:
* @handle: handle of the file for which information must be retrieved.
* @info: pointer to a #GnomeVFSFileInfo object that will hold the information
* for the file on return.
* @options: options for retrieving file information.
*
* Retrieve information about an open file. The information will be stored in
* @info.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_get_file_info_from_handle (GnomeVFSHandle *handle,
GnomeVFSFileInfo *info,
GnomeVFSFileInfoOptions options)
{
return gnome_vfs_get_file_info_from_handle_cancellable (handle, info,
options,
NULL);
}
/**
* gnome_vfs_truncate:
* @text_uri: string representing the file to be truncated.
* @length: length of the new file at @text_uri.
*
* Truncate the file at @text_uri to @length bytes.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_truncate (const char *text_uri, GnomeVFSFileSize length)
{
GnomeVFSURI *uri;
GnomeVFSResult result;
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_NOT_SUPPORTED;
result = gnome_vfs_truncate_uri(uri, length);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_truncate_uri:
* @uri: uri of the file to be truncated.
* @length: length of the new file at @uri.
*
* Truncate the file at @uri to be only @length bytes. Data past @length
* bytes will be discarded.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_truncate_uri (GnomeVFSURI *uri, GnomeVFSFileSize length)
{
return gnome_vfs_truncate_uri_cancellable(uri, length, NULL);
}
/**
* gnome_vfs_truncate_handle:
* @handle: a handle to the file to be truncated.
* @length: length of the new file the handle is open to.
*
* Truncate the file pointed to by @handle to be only @length bytes.
* Data past @length bytes will be discarded.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_truncate_handle (GnomeVFSHandle *handle, GnomeVFSFileSize length)
{
return gnome_vfs_truncate_handle_cancellable(handle, length, NULL);
}
/**
* gnome_vfs_make_directory_for_uri:
* @uri: uri of the directory to be created.
* @perm: Unix-style permissions for the newly created directory.
*
* Create a directory at @uri. Only succeeds if a file or directory
* does not already exist at @uri.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_make_directory_for_uri (GnomeVFSURI *uri,
guint perm)
{
return gnome_vfs_make_directory_for_uri_cancellable (uri, perm, NULL);
}
/**
* gnome_vfs_make_directory:
* @text_uri: uri of the directory to be created.
* @perm: Unix-style permissions for the newly created directory
*
* Create @text_uri as a directory.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_make_directory (const gchar *text_uri,
guint perm)
{
GnomeVFSResult result;
GnomeVFSURI *uri;
g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
result = gnome_vfs_make_directory_for_uri (uri, perm);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_remove_directory_from_uri:
* @uri: uri of the directory to be removed.
*
* Remove @uri. @uri must be an empty directory.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_remove_directory_from_uri (GnomeVFSURI *uri)
{
return gnome_vfs_remove_directory_from_uri_cancellable (uri, NULL);
}
/**
* gnome_vfs_remove_directory:
* @text_uri: path of the directory to be removed.
*
* Remove @text_uri. @text_uri must be an empty directory.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_remove_directory (const gchar *text_uri)
{
GnomeVFSResult result;
GnomeVFSURI *uri;
g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
result = gnome_vfs_remove_directory_from_uri (uri);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_unlink_from_uri:
* @uri: uri of the file to be unlinked.
*
* Unlink @uri (i.e. delete the file).
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_unlink_from_uri (GnomeVFSURI *uri)
{
return gnome_vfs_unlink_from_uri_cancellable (uri, NULL);
}
/**
* gnome_vfs_create_symbolic_link:
* @uri: uri to create a link at.
* @target_reference: uri "reference" to point the link to (uri or relative path).
*
* Creates a symbolic link, or eventually, a uri link (as necessary)
* at @uri pointing to @target_reference.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_create_symbolic_link (GnomeVFSURI *uri, const gchar *target_reference)
{
return gnome_vfs_create_symbolic_link_cancellable (uri, target_reference, NULL);
}
/**
* gnome_vfs_unlink:
* @text_uri: uri of the file to be unlinked.
*
* Unlink @text_uri (i.e. delete the file).
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_unlink (const gchar *text_uri)
{
GnomeVFSResult result;
GnomeVFSURI *uri;
g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
result = gnome_vfs_unlink_from_uri (uri);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_move_uri:
* @old_uri: source uri.
* @new_uri: destination uri.
* @force_replace: if %TRUE, move @old_uri to @new_uri even if there
* is already a file at @new_uri. If there is a file, it will be discarded.
*
* Move a file from uri @old_uri to @new_uri. This will only work if @old_uri
* and @new_uri are on the same file system. Otherwise, it is necessary
* to use the more general gnome_vfs_xfer_uri() function.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_move_uri (GnomeVFSURI *old_uri,
GnomeVFSURI *new_uri,
gboolean force_replace)
{
return gnome_vfs_move_uri_cancellable (old_uri, new_uri,
force_replace, NULL);
}
/**
* gnome_vfs_move:
* @old_text_uri: string representing the source file location.
* @new_text_uri: string representing the destination file location.
* @force_replace: if %TRUE, perform the operation even if it unlinks an existing
* file at @new_text_uri.
*
* Move a file from @old_text_uri to @new_text_uri. This will only work
* if @old_text_uri and @new_text_uri are on the same file system. Otherwise,
* it is necessary to use the more general gnome_vfs_xfer_uri() function.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_move (const gchar *old_text_uri,
const gchar *new_text_uri,
gboolean force_replace)
{
GnomeVFSURI *old_uri, *new_uri;
GnomeVFSResult retval;
g_return_val_if_fail (old_text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
g_return_val_if_fail (new_text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
old_uri = gnome_vfs_uri_new (old_text_uri);
if (old_uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
new_uri = gnome_vfs_uri_new (new_text_uri);
if (new_uri == NULL) {
gnome_vfs_uri_unref (old_uri);
return GNOME_VFS_ERROR_INVALID_URI;
}
retval = gnome_vfs_move_uri (old_uri, new_uri, force_replace);
gnome_vfs_uri_unref (old_uri);
gnome_vfs_uri_unref (new_uri);
return retval;
}
/**
* gnome_vfs_check_same_fs_uris:
* @source_uri: a uri.
* @target_uri: another uri.
* @same_fs_return: pointer to a boolean variable which will be set to %TRUE
* on return if @source_uri and @target_uri are on the same file system.
*
* Check if @source_uri and @target_uri are on the same file system.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_check_same_fs_uris (GnomeVFSURI *source_uri,
GnomeVFSURI *target_uri,
gboolean *same_fs_return)
{
return gnome_vfs_check_same_fs_uris_cancellable (source_uri,
target_uri,
same_fs_return,
NULL);
}
/**
* gnome_vfs_check_same_fs:
* @source: path to a file.
* @target: path to another file.
* @same_fs_return: pointer to a boolean variable which will be set to %TRUE
* on return if @source and @target are on the same file system.
*
* Check if @source and @target are on the same file system.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_check_same_fs (const gchar *source,
const gchar *target,
gboolean *same_fs_return)
{
GnomeVFSURI *a_uri, *b_uri;
GnomeVFSResult retval;
g_return_val_if_fail (source != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
g_return_val_if_fail (target != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
g_return_val_if_fail (same_fs_return != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
*same_fs_return = FALSE;
a_uri = gnome_vfs_uri_new (source);
if (a_uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
b_uri = gnome_vfs_uri_new (target);
if (b_uri == NULL) {
gnome_vfs_uri_unref (a_uri);
return GNOME_VFS_ERROR_INVALID_URI;
}
retval = gnome_vfs_check_same_fs_uris (a_uri, b_uri, same_fs_return);
gnome_vfs_uri_unref (a_uri);
gnome_vfs_uri_unref (b_uri);
return retval;
}
/**
* gnome_vfs_set_file_info_uri:
* @uri: a uri.
* @info: information that must be set for the file.
* @mask: bit mask representing which fields of @info need to be set.
*
* Set file information for @uri; only the information for which the
* corresponding bit in @mask is set is actually modified.
*
* <note>
* @info's %valid_fields is not required to contain the
* #GnomeVFSFileInfoFields corresponding to the specified
* #GnomeVFSSetFileInfoMask fields of @mask. It
* is assumed that the @info fields referenced by @mask
* are valid.
* </note>
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_set_file_info_uri (GnomeVFSURI *uri,
GnomeVFSFileInfo *info,
GnomeVFSSetFileInfoMask mask)
{
return gnome_vfs_set_file_info_cancellable (uri, info, mask, NULL);
}
/**
* gnome_vfs_set_file_info:
* @text_uri: string representing the file location.
* @info: information that must be set for the file.
* @mask: bit mask representing which fields of @info need to be set.
*
* Set file information for @uri; only the information for which the
* corresponding bit in @mask is set is actually modified.
*
* <note>
* @info's %valid_fields is not required to contain the
* #GnomeVFSFileInfoFields corresponding to the specified
* #GnomeVFSSetFileInfoMask fields of @mask. It
* is assumed that the @info fields referenced by @mask
* are valid.
* </note>
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_set_file_info (const gchar *text_uri,
GnomeVFSFileInfo *info,
GnomeVFSSetFileInfoMask mask)
{
GnomeVFSURI *uri;
GnomeVFSResult result;
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL)
return GNOME_VFS_ERROR_INVALID_URI;
result = gnome_vfs_set_file_info_uri (uri, info, mask);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_uri_exists:
* @uri: a uri.
*
* Check if the uri points to an existing entity.
*
* Return value: %TRUE if uri exists.
*/
gboolean
gnome_vfs_uri_exists (GnomeVFSURI *uri)
{
GnomeVFSFileInfo *info;
GnomeVFSResult result;
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info_uri (uri, info, GNOME_VFS_FILE_INFO_DEFAULT);
gnome_vfs_file_info_unref (info);
return result == GNOME_VFS_OK;
}
/**
* gnome_vfs_monitor_add:
* @handle: after the call, @handle will be a pointer to an operation handle.
* @text_uri: string representing the uri to monitor.
* @monitor_type: add a directory or file monitor.
* @callback: function to call when the monitor is tripped.
* @user_data: data to pass to @callback.
*
* Watch the file or directory at @text_uri for changes (or the creation/deletion of the file)
* and call @callback when there is a change. If a directory monitor is added, @callback is
* notified when any file in the directory changes.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_monitor_add (GnomeVFSMonitorHandle **handle,
const gchar *text_uri,
GnomeVFSMonitorType monitor_type,
GnomeVFSMonitorCallback callback,
gpointer user_data)
{
GnomeVFSURI *uri;
GnomeVFSResult result;
g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
*handle = NULL;
g_return_val_if_fail (text_uri != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
uri = gnome_vfs_uri_new (text_uri);
if (uri == NULL) {
return GNOME_VFS_ERROR_INVALID_URI;
}
if (!VFS_METHOD_HAS_FUNC(uri->method, monitor_add)) {
gnome_vfs_uri_unref (uri);
return GNOME_VFS_ERROR_NOT_SUPPORTED;
}
result = _gnome_vfs_monitor_do_add (uri->method, handle, uri,
monitor_type, callback,
user_data);
gnome_vfs_uri_unref (uri);
return result;
}
/**
* gnome_vfs_monitor_cancel:
* @handle: handle of the monitor to cancel.
*
* Cancel the monitor pointed to be @handle.
*
* Return value: an integer representing the result of the operation.
*/
GnomeVFSResult
gnome_vfs_monitor_cancel (GnomeVFSMonitorHandle *handle)
{
g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
return _gnome_vfs_monitor_do_cancel (handle);
}
/**
* gnome_vfs_file_control:
* @handle: handle of the file to affect.
* @operation: operation to execute.
* @operation_data: data needed to execute the operation.
*
* Execute a backend dependent operation specified by the string @operation.
* This is typically used for specialized vfs backends that need additional
* operations that gnome-vfs doesn't have. Compare it to the unix call ioctl().
* The format of @operation_data depends on the operation. Operation that are
* backend specific are normally namespaced by their module name.
*
* Return value: an integer representing the success of the operation.
*/
GnomeVFSResult
gnome_vfs_file_control (GnomeVFSHandle *handle,
const char *operation,
gpointer operation_data)
{
return gnome_vfs_file_control_cancellable (handle, operation, operation_data, NULL);
}
|