~ubuntu-branches/debian/experimental/glib2.0/experimental

« back to all changes in this revision

Viewing changes to gio/tests/gio-du.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2015-08-26 17:25:52 UTC
  • mfrom: (1.67.13)
  • Revision ID: package-import@ubuntu.com-20150826172552-c3rs5tllwng5cr46
Tags: 2.45.6-1
* New upstream releases 2.45.5 and 2.45.6
  + GNetworkMonitor now provides information about metered networks
  + g_mem_set_vtable has been deprecated; it has not been working for quite
    a while. The recommendation is to use valgrind, or replace malloc
    itself.
* debian/patches/0001-GOptionContext-Don-t-crash-without-main-group.patch:
  Drop, applied upstream.
* debian/libglib2.0-0.symbols: Add new symbols for this release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
static gint     outstanding_asyncs;
8
8
 
9
 
#ifdef G_OS_WIN32
10
 
typedef struct {
11
 
  int newmode;
12
 
} _startupinfo;
13
 
 
14
 
#ifndef _MSC_VER
15
 
 
16
 
extern void __wgetmainargs(int *argc,
17
 
                           wchar_t ***wargv,
18
 
                           wchar_t ***wenviron,
19
 
                           int expand_wildcards,
20
 
                           _startupinfo *startupinfo);
21
 
#endif
22
 
#endif
23
 
 
24
9
static void
25
10
print_result (const gchar *filename,
26
11
              guint64      disk_usage,
91
76
  GFileMeasureProgressCallback progress = NULL;
92
77
  GFileMeasureFlags flags = 0;
93
78
  gint i;
 
79
 
94
80
#ifdef G_OS_WIN32
95
 
  int wargc;
96
 
  wchar_t **wargv, **wenvp;
97
 
  _startupinfo si = { 0 };
98
 
 
99
 
  __wgetmainargs (&wargc, &wargv, &wenvp, 0, &si);
 
81
  argv = g_win32_get_command_line ();
 
82
  argc = g_strv_length (argv);
100
83
#endif
101
84
 
102
85
  setlocale (LC_ALL, "");
111
94
      if (g_str_equal (argv[i], "--help"))
112
95
        {
113
96
          g_print ("usage: du [--progress] [--async] [-x] [-h] [-h] [--apparent-size] [--any-error] [--] files...\n");
 
97
#ifdef G_OS_WIN32
 
98
          g_strfreev (argv);
 
99
#endif
114
100
          return 0;
115
101
        }
116
102
      else if (g_str_equal (argv[i], "-x"))
134
120
  if (!argv[i])
135
121
    {
136
122
      g_printerr ("usage: du [--progress] [--async] [-x] [-h] [-h] [--apparent-size] [--any-error] [--] files...\n");
 
123
#ifdef G_OS_WIN32
 
124
      g_strfreev (argv);
 
125
#endif
137
126
      return 1;
138
127
    }
139
128
 
140
 
#ifdef G_OS_WIN32
141
 
  while (wargv[i])
142
 
  {
143
 
    gchar *argv_utf8 = g_utf16_to_utf8 (wargv[i], -1, NULL, NULL, NULL);
144
 
#else
145
129
  while (argv[i])
146
130
  {
147
 
    gchar *argv_utf8 = g_strdup (argv[i]);
148
 
#endif
149
 
    GFile *file = g_file_new_for_commandline_arg (argv_utf8);
 
131
    GFile *file = g_file_new_for_commandline_arg (argv[i]);
150
132
 
151
133
    if (option_use_async)
152
134
    {
153
135
      g_file_measure_disk_usage_async (file, flags, G_PRIORITY_DEFAULT, NULL,
154
 
                                       progress, argv_utf8, async_ready_func, argv_utf8);
 
136
                                       progress, argv[i], async_ready_func, argv[i]);
155
137
      outstanding_asyncs++;
156
138
    }
157
139
    else
161
143
      guint64 num_dirs;
162
144
      guint64 num_files;
163
145
 
164
 
      g_file_measure_disk_usage (file, flags, NULL, progress, argv_utf8,
 
146
      g_file_measure_disk_usage (file, flags, NULL, progress, argv[i],
165
147
                                 &disk_usage, &num_dirs, &num_files, &error);
166
 
      print_result (argv_utf8, disk_usage, num_dirs, num_files, error, '\n');
167
 
      g_free (argv_utf8);
 
148
      print_result (argv[i], disk_usage, num_dirs, num_files, error, '\n');
168
149
    }
169
150
 
170
151
    g_object_unref (file);
175
156
  while (outstanding_asyncs)
176
157
    g_main_context_iteration (NULL, TRUE);
177
158
 
 
159
#ifdef G_OS_WIN32
 
160
  g_strfreev (argv);
 
161
#endif
 
162
 
178
163
  return 0;
179
164
}