glib2.0/debian/patches/20210325-file-type.patch

136 lines
4.4 KiB
Diff
Raw Normal View History

2023-02-15 16:51:32 +08:00
From: Debian GNOME Maintainers
<pkg-gnome-maintainers@lists.alioth.debian.org>
Date: Wed, 29 Jun 2022 08:02:49 +0000
Subject: file-type
===================================================================
---
gio/gfile.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
po/zh_CN.po | 3 +++
2 files changed, 73 insertions(+)
diff --git a/gio/gfile.c b/gio/gfile.c
index a2ded14..e37bc36 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -39,6 +39,9 @@
#include <string.h>
#include <sys/types.h>
+#include <mntent.h>
+#include <sys/vfs.h>
+#include <syslog.h>
#include "gfile.h"
#include "glib/gstdio.h"
@@ -339,6 +342,29 @@ static gboolean g_file_real_measure_disk_usage_finish (GFile
guint64 *num_files,
GError **error);
+static const char* get_fs_type (char* path)
+{
+ const char* fs_type = NULL;
+ struct mntent* m = NULL;
+ FILE* f = NULL;
+
+ f = setmntent ("/etc/mtab", "r");
+ if (!f) {
+ syslog (LOG_ERR, "error:%s", strerror(errno));
+ }
+
+ while ((m = getmntent(f))) {
+ if (!path) continue;
+ if (!m->mnt_dir) continue;
+ if (!strcmp (path, m->mnt_dir)) {
+ fs_type = g_strdup_printf("%s", m->mnt_type);
+ }
+ }
+ endmntent (f);
+
+ return fs_type;
+}
+
typedef GFileIface GFileInterface;
G_DEFINE_INTERFACE (GFile, g_file, G_TYPE_OBJECT)
@@ -3457,10 +3483,32 @@ g_file_copy (GFile *source,
GFileIface *iface;
GError *my_error;
gboolean res;
+ const char* fs_type;
+ GMount* destination_mount;
+ GFile* root;
+ struct stat s;
g_return_val_if_fail (G_IS_FILE (source), FALSE);
g_return_val_if_fail (G_IS_FILE (destination), FALSE);
+ destination_mount = g_file_find_enclosing_mount(g_file_get_parent(destination), NULL, NULL);
+ if ( destination_mount != NULL) {
+ root = g_mount_get_default_location (destination_mount);
+ fs_type = get_fs_type (g_file_get_path(root));
+ if(fs_type != NULL) {
+ if(!strcmp(fs_type,"vfat") || !strcmp(fs_type,"fat32")) {
+ if (stat(g_file_get_path(source), &s) == 0) {
+ if(s.st_size > 4294967296) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("The file is too large, the fat format file system only supports files within 4G,can be imported in device after compression"));
+ return FALSE;
+ }
+ }
+ }
+
+ g_free(fs_type);
+ }
+ }
+
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
@@ -3659,10 +3707,32 @@ g_file_move (GFile *source,
GFileIface *iface;
GError *my_error;
gboolean res;
+ const char* fs_type;
+ GMount* destination_mount;
+ GFile* root;
+ struct stat s;
g_return_val_if_fail (G_IS_FILE (source), FALSE);
g_return_val_if_fail (G_IS_FILE (destination), FALSE);
+ destination_mount = g_file_find_enclosing_mount(g_file_get_parent(destination), NULL, NULL);
+ if ( destination_mount != NULL) {
+ root = g_mount_get_default_location (destination_mount);
+
+ fs_type = get_fs_type (g_file_get_path(root));
+ if(fs_type != NULL) {
+ if(!strcmp(fs_type,"vfat") || !strcmp(fs_type,"fat32")) {
+ if (stat(g_file_get_path(source), &s) == 0) {
+ if(s.st_size > 4294967296) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("The file is too large, the fat format file system only supports files within 4G,can be moved in device after compression"));
+ return FALSE;
+ }
+ }
+ }
+ g_free(fs_type);
+ }
+ }
+
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 4e4adb5..1a46756 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -43,6 +43,9 @@ msgstr "GApplication 选项"
msgid "Show GApplication options"
msgstr "显示 GApplication 选项"
+msgid "The file is too large, the fat format file system only supports files within 4G,can be imported in device after compression"
+msgstr "文件太大fat格式文件系统只支持4G以内的文件压缩后可以导入设备"
+
#: ../gio/gapplication.c:538
msgid "Enter GApplication service mode (use from D-Bus service files)"
msgstr "进入 GApplication 服务模式(从 D-Bus 服务文件中调用)"