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
|
XDG_VFS_KDE
===========
!!! hint: to turn off the error messages run kdebugdialog !!!
xdg_vfs_kde is a command line client for KIO. It can read and write
files, list directories, open file-dialogs,... File-data is not stored in
temporary files, but instead is pushed/pulled via stdin and stdout.
The aim of 'xdg_vfs_kde' is to give third party desktop applications access
to KIO. It could be hidden behind a generic 'xdg_vfs' script, which switches between KIO,
Gnome-VFS,... command line clients.
Samples:
========
-) reading a file
$ xdg_vfs_kde get file:///etc/lilo.conf
$ xdg_vfs_kde get http://www.freedesktop.org
will stream a remote file to stdout which could be read into the hosts
applications memory via the C-function popen(..,'r');
$ xdg_vfs_kde openfiledlg --instant-get
will open a file-dialog to browse to a remote or local file and instantly
stream the file-data of the selected file to stdout.
$ xdg_vfs_kde openfiledlg --instant-get --qry-fileinfo --slow-mime --tagged
By adding those switches xdg_vfs_kde will also 'stat' the remote file and
try to detect it's mime-type, size,...
-) writing a file
$ cat /etc/passwd | xdg_vfs_kde put ftp://user@host/mydir/file.txt
or use something like popen(..,'w') to stream file-data to create a remote file.
-) listing a directory
$ xdg_vfs_kde ls sftp://user@host/dir/
There are two operation modes:
==============================
*) single command
*) shell mode (like the command-line ftp client). In shell mode the
host application can talk to 'xdg_vfs_kde' by connecting to the
stdin and stdout pipes to execute a sequence of vfs commands.
(for instance QProcess or functions like g_spawn_async_with_pipes() allow
connecting to stdin and stdout of a child process)
The advantage of shell mode is that passwords are kept in memory
(the user doesn't have log in again and again) and avoiding startup-delay
when executing multiple commands (for instance if the client application
is a file-manager)
Tagged-mode:
============
the -t, --tagged option tells xdg_vfs_kde to add 'labels' when a command
returns multiple 'parts'. For instance
> xdg_vfs_kde openfiledlg --instant-get --qry-fileinfo --tagged
will return an [OpenFileDlg], a [FileInfo] and a [Data] section.
Escaping file data:
===================
When operating in shell- or tagged- mode you will need an escape character
to signal the end of binary data. This is done via the -e and --escape-data
switch. By default '~' is the escape character. '~~' has to be treated as
single '~' and '~\n' as EOF. The escape-character can be changed by
the -e35 or --escape-data=35 option. (when you want to use '#' ASCII 35 as escape
character)
Usage screen:
=============
Usage: xdg_vfs [command] [options] [filename]
Commands:
get [filename] : remote file->stdout
info [file or dir] : stat a remote file->stdout
put [filename] : stdin->create remote file
ls [dir] : list directory
openfiledlg [dir] : show open file dialog and return selected file
savefiledlg [dir] [fname] : show save file dialog and return selected file
shell : interactive mode
Options:
-t, --tagged : tagged mode (file-data should be escaped)
-i, --qry-fileinfo : qry file-info when retrieving a file
--show-metadata : show metadata when retrieving a file
requires tagged mode!
-m, --slow-mime : more accurate mime-type detection (slow)
-e, --escape-data : escape file data (for end of data detection)
-eXXX, --escape-data=XXX : set and use a user defined escape character
XXX = ascii code!
--end-seperator= : add a custom seperator inbetween blocks
--overwrite : allow overwriting files (put)
--instant-get : openfiledilog instant get file->stdout
--instant-put : savefiledilog instant put file from stdin
|