2 * Copyright (C) 2006 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include "ui-fileops.h"
34 #include "filefilter.h"
37 #include "secure-save.h"
40 *-----------------------------------------------------------------------------
41 * generic file information and manipulation routines (public)
42 *-----------------------------------------------------------------------------
47 void print_term(gboolean err, const gchar *text_utf8)
51 text_l = g_locale_from_utf8(text_utf8, -1, nullptr, nullptr, nullptr);
54 fputs((text_l) ? text_l : text_utf8, stderr);
58 fputs((text_l) ? text_l : text_utf8, stdout);
60 if(command_line && command_line->ssi)
61 secure_fputs(command_line->ssi, (text_l) ? text_l : text_utf8);
65 static void encoding_dialog(const gchar *path)
67 static gboolean warned_user = FALSE;
73 if (warned_user) return;
77 bf = getenv("G_BROKEN_FILENAMES");
79 string = g_string_new("");
80 g_string_append(string, _("One or more filenames are not encoded with the preferred locale character set.\n"));
81 g_string_append_printf(string, _("Operations on, and display of these files with %s may not succeed.\n"), PACKAGE);
82 g_string_append(string, "\n");
83 g_string_append(string, _("If your filenames are not encoded in utf-8, try setting the environment variable G_BROKEN_FILENAMES=1\n"));
85 g_string_append_printf(string, _("It appears G_BROKEN_FILENAMES is set to %s\n"), bf);
87 g_string_append(string, _("It appears G_BROKEN_FILENAMES is not set\n"));
88 g_string_append(string, "\n");
89 g_string_append_printf(string, _("The locale appears to be set to \"%s\"\n(set by the LANG environment variable)\n"), (lc) ? lc : "undefined");
90 if (lc && (strstr(lc, "UTF-8") || strstr(lc, "utf-8")))
93 name = g_convert(path, -1, "UTF-8", "ISO-8859-1", nullptr, nullptr, nullptr);
94 string = g_string_append(string, _("\nPreferred encoding appears to be UTF-8, however the file:\n"));
95 g_string_append_printf(string, "\"%s\"\n", (name) ? name : _("[name not displayable]"));
97 if (g_utf8_validate(path, -1, nullptr))
98 g_string_append_printf(string, _("\"%s\" is encoded in valid UTF-8."), (name) ? name : _("[name not displayable]"));
100 g_string_append_printf(string, _("\"%s\" is not encoded in valid UTF-8."), (name) ? name : _("[name not displayable]"));
101 g_string_append(string, "\n");
105 gd = generic_dialog_new(_("Filename encoding locale mismatch"),
106 "locale warning", nullptr, TRUE, nullptr, nullptr);
107 generic_dialog_add_button(gd, GQ_ICON_CLOSE, _("Close"), nullptr, TRUE);
109 generic_dialog_add_message(gd, GQ_ICON_DIALOG_WARNING,
110 _("Filename encoding locale mismatch"), string->str, TRUE);
112 gtk_widget_show(gd->dialog);
114 g_string_free(string, TRUE);
117 #if GQ_DEBUG_PATH_UTF8
118 gchar *path_to_utf8_debug(const gchar *path, const gchar *file, gint line)
120 gchar *path_to_utf8(const gchar *path)
124 GError *error = nullptr;
126 if (!path) return nullptr;
128 utf8 = g_filename_to_utf8(path, -1, nullptr, nullptr, &error);
131 #if GQ_DEBUG_PATH_UTF8
132 log_printf("%s:%d: Unable to convert filename to UTF-8:\n%s\n%s\n", file, line, path, error->message);
134 log_printf("Unable to convert filename to UTF-8:\n%s\n%s\n", path, error->message);
137 encoding_dialog(path);
141 /* just let it through, but bad things may happen */
142 utf8 = g_strdup(path);
148 #if GQ_DEBUG_PATH_UTF8
149 gchar *path_from_utf8_debug(const gchar *utf8, const gchar *file, gint line)
151 gchar *path_from_utf8(const gchar *utf8)
155 GError *error = nullptr;
157 if (!utf8) return nullptr;
159 path = g_filename_from_utf8(utf8, -1, nullptr, nullptr, &error);
162 #if GQ_DEBUG_PATH_UTF8
163 log_printf("%s:%d: Unable to convert filename to locale from UTF-8:\n%s\n%s\n", file, line, utf8, error->message);
165 log_printf("Unable to convert filename to locale from UTF-8:\n%s\n%s\n", utf8, error->message);
171 /* if invalid UTF-8, text probably still in original form, so just copy it */
172 path = g_strdup(utf8);
178 /* first we try the HOME environment var, if that doesn't work, we try g_get_homedir(). */
179 const gchar *homedir()
181 static gchar *home = nullptr;
184 home = path_to_utf8(getenv("HOME"));
187 home = path_to_utf8(g_get_home_dir());
189 DEBUG_1("Home directory: %s", home);
194 static gchar *xdg_dir_get(const gchar *key, const gchar *fallback)
196 gchar *dir = getenv(key);
198 if (!dir || dir[0] == '\0')
200 return g_build_filename(homedir(), fallback, NULL);
203 DEBUG_1("Got xdg %s: %s", key, dir);
205 return path_to_utf8(dir);
208 const gchar *xdg_data_home_get()
210 static const gchar *xdg_data_home = nullptr;
212 if (xdg_data_home) return xdg_data_home;
214 xdg_data_home = xdg_dir_get("XDG_DATA_HOME", ".local/share");
216 return xdg_data_home;
219 const gchar *xdg_config_home_get()
221 static const gchar *xdg_config_home = nullptr;
223 if (xdg_config_home) return xdg_config_home;
225 xdg_config_home = xdg_dir_get("XDG_CONFIG_HOME", ".config");
227 return xdg_config_home;
230 const gchar *xdg_cache_home_get()
232 static const gchar *xdg_cache_home = nullptr;
234 if (xdg_cache_home) return xdg_cache_home;
236 xdg_cache_home = xdg_dir_get("XDG_CACHE_HOME", ".cache");
238 return xdg_cache_home;
241 const gchar *get_rc_dir()
243 static gchar *rc_dir = nullptr;
245 if (rc_dir) return rc_dir;
249 rc_dir = g_build_filename(xdg_config_home_get(), GQ_APPNAME_LC, NULL);
253 rc_dir = g_build_filename(homedir(), GQ_RC_DIR, NULL);
259 const gchar *get_collections_dir()
261 static gchar *collections_dir = nullptr;
263 if (collections_dir) return collections_dir;
267 collections_dir = g_build_filename(xdg_data_home_get(), GQ_APPNAME_LC, GQ_COLLECTIONS_DIR, NULL);
271 collections_dir = g_build_filename(get_rc_dir(), GQ_COLLECTIONS_DIR, NULL);
274 return collections_dir;
277 const gchar *get_trash_dir()
279 static gchar *trash_dir = nullptr;
281 if (trash_dir) return trash_dir;
285 trash_dir = g_build_filename(xdg_data_home_get(), GQ_APPNAME_LC, GQ_TRASH_DIR, NULL);
289 trash_dir = g_build_filename(get_rc_dir(), GQ_TRASH_DIR, NULL);
295 const gchar *get_window_layouts_dir()
297 static gchar *window_layouts_dir = nullptr;
299 if (window_layouts_dir) return window_layouts_dir;
303 window_layouts_dir = g_build_filename(xdg_config_home_get(), GQ_APPNAME_LC, GQ_WINDOW_LAYOUTS_DIR, NULL);
307 window_layouts_dir = g_build_filename(get_rc_dir(), GQ_WINDOW_LAYOUTS_DIR, NULL);
310 return window_layouts_dir;
313 gboolean stat_utf8(const gchar *s, struct stat *st)
318 if (!s) return FALSE;
319 sl = path_from_utf8(s);
320 ret = (stat(sl, st) == 0);
326 gboolean lstat_utf8(const gchar *s, struct stat *st)
331 if (!s) return FALSE;
332 sl = path_from_utf8(s);
333 ret = (lstat(sl, st) == 0);
339 gboolean isname(const gchar *s)
343 return stat_utf8(s, &st);
346 gboolean isfile(const gchar *s)
350 return (stat_utf8(s, &st) && S_ISREG(st.st_mode));
353 gboolean isdir(const gchar *s)
357 return (stat_utf8(s, &st) && S_ISDIR(st.st_mode));
360 gboolean islink(const gchar *s)
364 return (lstat_utf8(s, &st) && S_ISLNK(st.st_mode));
367 gint64 filesize(const gchar *s)
371 if (!stat_utf8(s, &st)) return 0;
375 time_t filetime(const gchar *s)
379 if (!stat_utf8(s, &st)) return 0;
383 gboolean filetime_set(const gchar *s, time_t tval)
385 gboolean ret = FALSE;
392 ut.actime = ut.modtime = tval;
394 sl = path_from_utf8(s);
395 ret = (utime(sl, &ut) == 0);
402 gboolean is_readable_file(const gchar *s)
404 if (!s || !s[0] || !isfile(s)) return FALSE;
405 return access_file(s, R_OK);
408 gboolean access_file(const gchar *s, gint mode)
413 if (!s || !s[0]) return FALSE;
415 sl = path_from_utf8(s);
416 ret = (access(sl, mode) == 0);
422 gboolean unlink_file(const gchar *s)
427 if (!s) return FALSE;
429 sl = path_from_utf8(s);
430 ret = (unlink(sl) == 0);
436 #pragma GCC diagnostic push
437 #pragma GCC diagnostic ignored "-Wunused-function"
438 gboolean symlink_utf8_unused(const gchar *source, const gchar *target)
444 if (!source || !target) return FALSE;
446 sl = path_from_utf8(source);
447 tl = path_from_utf8(target);
449 ret = (symlink(sl, tl) == 0);
456 #pragma GCC diagnostic pop
458 gboolean mkdir_utf8(const gchar *s, gint mode)
463 if (!s) return FALSE;
465 sl = path_from_utf8(s);
466 ret = (mkdir(sl, mode) == 0);
471 gboolean rmdir_utf8(const gchar *s)
476 if (!s) return FALSE;
478 sl = path_from_utf8(s);
479 ret = (rmdir(sl) == 0);
485 gboolean copy_file_attributes(const gchar *s, const gchar *t, gint perms, gint mtime)
489 gboolean ret = FALSE;
491 if (!s || !t) return FALSE;
493 sl = path_from_utf8(s);
494 tl = path_from_utf8(t);
496 if (stat(sl, &st) == 0)
502 /* set the dest file attributes to that of source (ignoring errors) */
506 ret = chown(tl, st.st_uid, st.st_gid);
507 /* Ignores chown errors, while still doing chown
508 (so root still can copy files preserving ownership) */
510 if (chmod(tl, st.st_mode) < 0) {
512 if (stat(tl, &st2) != 0 || st2.st_mode != st.st_mode) {
518 tb.actime = st.st_atime;
519 tb.modtime = st.st_mtime;
520 if (mtime && utime(tl, &tb) < 0) ret = FALSE;
529 /* paths are in filesystem encoding */
530 static gboolean hard_linked(const gchar *a, const gchar *b)
535 if (stat(a, &sta) != 0 || stat(b, &stb) != 0) return FALSE;
537 return (sta.st_dev == stb.st_dev &&
538 sta.st_ino == stb.st_ino);
541 static void fclose_safe(FILE *fp)
546 gboolean copy_file(const gchar *s, const gchar *t)
552 std::unique_ptr<gchar, decltype(&g_free)> sl{path_from_utf8(s), g_free};
553 std::unique_ptr<gchar, decltype(&g_free)> tl{path_from_utf8(t), g_free};
555 if (hard_linked(sl.get(), tl.get()))
560 /* Do not dereference absolute symlinks, but copy them "as is".
561 * For a relative symlink, we don't know how to properly change it when
562 * copied/moved to another dir to keep pointing it to same target as
563 * a relative symlink, so we turn it into absolute symlink using
564 * realpath() instead. */
565 auto copy_symlink = [](const gchar *sl, const gchar *tl) -> gboolean
568 if (!lstat_utf8(sl, &st) && S_ISLNK(st.st_mode))
576 link_target = static_cast<gchar *>(g_malloc(st.st_size + 1));
577 i = readlink(sl, link_target, st.st_size);
581 return FALSE; // try a "normal" copy
583 link_target[st.st_size] = '\0';
585 if (link_target[0] != G_DIR_SEPARATOR) // if it is a relative symlink
589 const gchar *lastslash = strrchr(sl, G_DIR_SEPARATOR);
590 gint len = lastslash - sl + 1;
592 absolute = static_cast<gchar *>(g_malloc(len + st.st_size + 1));
593 strncpy(absolute, sl, len);
594 strcpy(absolute + len, link_target);
596 link_target = absolute;
599 realPath = realpath(link_target, nullptr);
601 if (realPath != nullptr) // successfully resolved into an absolute path
604 link_target = g_strdup(realPath);
607 else // could not get absolute path, got some error instead
610 return FALSE; // so try a "normal" copy
614 if (stat_utf8(tl, &st)) unlink(tl); // first try to remove directory entry in destination directory if such entry exists
616 gint success = (symlink(link_target, tl) == 0);
622 if (copy_symlink(sl.get(), tl.get()))
627 // if symlink did not succeed, continue on to try a copy procedure
628 std::unique_ptr<FILE, decltype(&fclose_safe)> fi{fopen(sl.get(), "rb"), fclose_safe};
634 /* First we write to a temporary file, then we rename it on success,
635 and attributes from original file are copied */
636 std::unique_ptr<gchar, decltype(&g_free)> randname{g_strconcat(tl.get(), ".tmp_XXXXXX", NULL), g_free};
642 fd = g_mkstemp(randname.get());
648 std::unique_ptr<FILE, decltype(&fclose_safe)> fo{fdopen(fd, "wb"), fclose_safe};
654 while ((b = fread(buf, sizeof(gchar), sizeof(buf), fi.get())) && b != 0)
656 if (fwrite(buf, sizeof(gchar), b, fo.get()) != b)
658 unlink(randname.get());
663 if (rename(randname.get(), tl.get()) < 0) {
664 unlink(randname.get());
668 return copy_file_attributes(s, t, TRUE, TRUE);
671 gboolean move_file(const gchar *s, const gchar *t)
676 if (!s || !t) return FALSE;
678 sl = path_from_utf8(s);
679 tl = path_from_utf8(t);
680 if (rename(sl, tl) < 0)
682 /* this may have failed because moving a file across filesystems
683 was attempted, so try copy and delete instead */
688 /* err, now we can't delete the source file so return FALSE */
703 gboolean rename_file(const gchar *s, const gchar *t)
708 if (!s || !t) return FALSE;
710 sl = path_from_utf8(s);
711 tl = path_from_utf8(t);
712 ret = (rename(sl, tl) == 0);
719 gchar *get_current_dir()
724 pathl = g_get_current_dir();
725 path8 = path_to_utf8(pathl);
731 void string_list_free(GList *list)
733 g_list_free_full(list, g_free);
736 GList *string_list_copy(const GList *list)
738 GList *new_list = nullptr;
739 auto work = const_cast<GList *>(list);
745 path = static_cast<gchar *>(work->data);
748 new_list = g_list_prepend(new_list, g_strdup(path));
751 return g_list_reverse(new_list);
754 gchar *unique_filename(const gchar *path, const gchar *ext, const gchar *divider, gboolean pad)
760 if (!divider) divider = "";
762 unique = g_strconcat(path, ext, NULL);
763 while (isname(unique))
768 unique = g_strdup_printf("%s%s%03d%s", path, divider, n, ext);
772 unique = g_strdup_printf("%s%s%d%s", path, divider, n, ext);
786 #pragma GCC diagnostic push
787 #pragma GCC diagnostic ignored "-Wunused-function"
788 gchar *unique_filename_simple_unused(const gchar *path)
794 if (!path) return NULL;
796 name = filename_from_path(path);
797 if (!name) return NULL;
799 ext = registered_extension_from_path(name);
803 unique = unique_filename(path, NULL, "_", TRUE);
809 base = remove_extension_from_path(path);
810 unique = unique_filename(base, ext, "_", TRUE);
816 #pragma GCC diagnostic pop
818 const gchar *filename_from_path(const gchar *path)
822 if (!path) return nullptr;
824 base = strrchr(path, G_DIR_SEPARATOR);
825 if (base) return base + 1;
830 gchar *remove_level_from_path(const gchar *path)
834 if (!path) return g_strdup("");
836 base = strrchr(path, G_DIR_SEPARATOR);
837 /* Take account of a file being in the root ( / ) folder - ensure the returned value
838 * is at least one character long */
839 if (base) return g_strndup(path, (strlen(path)-strlen(base)) == 0 ? 1 : (strlen(path)-strlen(base)));
844 gboolean file_extension_match(const gchar *path, const gchar *ext)
849 if (!path) return FALSE;
850 if (!ext) return TRUE;
856 return (p > e && g_ascii_strncasecmp(path + p - e, ext, e) == 0);
859 gchar *remove_extension_from_path(const gchar *path)
861 const gchar *reg_ext;
863 if (!path) return nullptr;
865 reg_ext = registered_extension_from_path(path);
867 return g_strndup(path, strlen(path) - (reg_ext == nullptr ? 0 : strlen(reg_ext)));
870 void parse_out_relatives(gchar *path)
878 while (path[s] != '\0')
880 if (path[s] == G_DIR_SEPARATOR && path[s+1] == '.')
882 /* /. occurrence, let's see more */
885 if (path[p] == G_DIR_SEPARATOR || path[p] == '\0')
887 /* /./ or /., just skip this part */
891 else if (path[p] == '.' && (path[p+1] == G_DIR_SEPARATOR || path[p+1] == '\0'))
893 /* /../ or /.., remove previous part, ie. /a/b/../ becomes /a/ */
896 while (path[t] != G_DIR_SEPARATOR && t > 0) t--;
901 if (s != t) path[t] = path[s];
906 if (t == 0 && path[t] == G_DIR_SEPARATOR) t++;
907 if (t > 1 && path[t-1] == G_DIR_SEPARATOR) t--;
911 gboolean file_in_path(const gchar *name)
916 gboolean ret = FALSE;
918 if (!name) return FALSE;
919 path = g_strdup(getenv("PATH"));
920 if (!path) return FALSE;
921 namel = path_from_utf8(name);
925 while (p < l && !ret)
929 while (path[e] != ':' && path[e] != '\0') e++;
932 f = g_build_filename(path + p, namel, NULL);
933 if (isfile(f)) ret = TRUE;
943 gboolean recursive_mkdir_if_not_exists(const gchar *path, mode_t mode)
945 if (!path) return FALSE;
949 gchar *npath = g_strdup(path);
955 if (p[0] == G_DIR_SEPARATOR || p[0] == '\0')
967 DEBUG_1("creating sub dir:%s", npath);
968 if (!mkdir_utf8(npath, mode))
970 log_printf("create dir failed: %s\n", npath);
976 if (!end) p[0] = G_DIR_SEPARATOR;
985 /* does filename utf8 to filesystem encoding first */
986 gboolean md5_get_digest_from_file_utf8(const gchar *path, guchar digest[16])
991 pathl = path_from_utf8(path);
992 success = md5_get_digest_from_file(pathl, digest);
999 gchar *md5_text_from_file_utf8(const gchar *path, const gchar *error_text)
1001 std::unique_ptr<gchar, decltype(&g_free)> pathl{path_from_utf8(path), g_free};
1003 auto md5_text = md5_get_string_from_file(pathl.get());
1005 return md5_text ? md5_text : g_strdup(error_text);
1008 /* Download web file
1013 GCancellable *cancellable;
1016 GtkWidget *progress;
1021 static void web_file_async_ready_cb(GObject *source_object, GAsyncResult *res, gpointer data)
1023 GError *error = nullptr;
1024 auto web = static_cast<WebData *>(data);
1025 gchar *tmp_filename;
1027 if (!g_cancellable_is_cancelled(web->cancellable))
1029 generic_dialog_close(web->gd);
1032 if (g_file_copy_finish(G_FILE(source_object), res, &error))
1034 tmp_filename = g_file_get_parse_name(web->tmp_g_file);
1035 g_free(tmp_filename);
1036 layout_set_path(web->lw, g_file_get_path(web->tmp_g_file));
1040 file_util_warning_dialog(_("Web file download failed"), error->message, GQ_ICON_DIALOG_ERROR, nullptr);
1043 g_object_unref(web->tmp_g_file);
1044 web->tmp_g_file = nullptr;
1045 g_object_unref(web->cancellable);
1046 g_object_unref(web->web_file);
1049 static void web_file_progress_cb(goffset current_num_bytes, goffset total_num_bytes, gpointer data)
1051 auto web = static_cast<WebData *>(data);
1053 if (!g_cancellable_is_cancelled(web->cancellable))
1055 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(web->progress), static_cast<gdouble>(current_num_bytes) / total_num_bytes);
1059 static void download_web_file_cancel_button_cb(GenericDialog *, gpointer data)
1061 auto web = static_cast<WebData *>(data);
1063 g_cancellable_cancel(web->cancellable);
1066 gboolean download_web_file(const gchar *text, gboolean minimized, gpointer data)
1069 auto lw = static_cast<LayoutWindow *>(data);
1071 GError *error = nullptr;
1074 gboolean ret = FALSE;
1076 FileFormatClass format_class;
1078 scheme = g_uri_parse_scheme(text);
1079 if (g_strcmp0("http", scheme) == 0 || g_strcmp0("https", scheme) == 0)
1081 format_class = filter_file_get_class(text);
1083 if (format_class == FORMAT_CLASS_IMAGE || format_class == FORMAT_CLASS_RAWIMAGE || format_class == FORMAT_CLASS_VIDEO || format_class == FORMAT_CLASS_DOCUMENT)
1085 tmp_dir = g_dir_make_tmp("geeqie_XXXXXX", &error);
1088 log_printf("Error: could not create temporary file n%s\n", error->message);
1089 g_error_free(error);
1095 web = g_new0(WebData, 1);
1098 web->web_file = g_file_new_for_uri(text);
1100 base = g_strdup(g_file_get_basename(web->web_file));
1101 web->tmp_g_file = g_file_new_for_path(g_build_filename(tmp_dir, base, NULL));
1103 web->gd = generic_dialog_new(_("Download web file"), "download_web_file", nullptr, TRUE, download_web_file_cancel_button_cb, web);
1105 message = g_strconcat(_("Downloading "), base, NULL);
1106 generic_dialog_add_message(web->gd, GQ_ICON_DIALOG_INFO, message, nullptr, FALSE);
1108 web->progress = gtk_progress_bar_new();
1109 gtk_box_pack_start(GTK_BOX(web->gd->vbox), web->progress, FALSE, FALSE, 0);
1110 gtk_widget_show(web->progress);
1113 gtk_window_iconify(GTK_WINDOW(web->gd->dialog));
1116 gtk_widget_show(web->gd->dialog);
1117 web->cancellable = g_cancellable_new();
1118 g_file_copy_async(web->web_file, web->tmp_g_file, G_FILE_COPY_OVERWRITE, G_PRIORITY_LOW, web->cancellable, web_file_progress_cb, web, web_file_async_ready_cb, web);
1136 gboolean rmdir_recursive(GFile *file, GCancellable *cancellable, GError **error)
1138 g_autoptr(GFileEnumerator) enumerator = nullptr;
1140 enumerator = g_file_enumerate_children(file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, nullptr);
1142 while (enumerator != nullptr)
1146 if (!g_file_enumerator_iterate(enumerator, nullptr, &child, cancellable, error))
1148 if (child == nullptr)
1150 if (!rmdir_recursive(child, cancellable, error))
1154 return g_file_delete(file, cancellable, error);
1158 * @brief Retrieves the internal scale factor that maps from window coordinates to the actual device pixels
1160 * @returns scale factor
1166 LayoutWindow *lw = nullptr;
1169 return gtk_widget_get_scale_factor(lw->window);
1171 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */