shithub: riscv

Download patch

ref: f21719ea46e6c060cc8fadaffb41b7dfb89be62e
parent: 092930f337275fba85be63a6fbbb34720b9e73fe
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Fri Nov 4 18:39:43 EDT 2011

file: recognize .ico and .cur files

--- a/sys/src/cmd/file.c
+++ b/sys/src/cmd/file.c
@@ -155,6 +155,7 @@
 int	isp9font(void);
 int	isrtf(void);
 int	ismsdos(void);
+int	isicocur(void);
 int	iself(void);
 int	istring(void);
 int	isoffstr(void);
@@ -192,6 +193,7 @@
 	isp9bit,	/* plan 9 image (as from /dev/window) */
 	isrtf,		/* rich text format */
 	ismsdos,	/* msdos exe (virus file attachement) */
+	isicocur,		/* windows icon or cursor file */
 	isface,		/* ascii face file */
 
 	/* last resorts */
@@ -871,7 +873,7 @@
 	ulong	off;
 	struct FILE_STRING;
 } offstrs[] = {
-	32*1024, "\001CD001\001",	"ISO9660 CD image",	7,	OCTET,
+	32*1024, "\001CD001\001",	"ISO9660 CD image",	7,	"application/x-iso9660-image",
 	0, 0, 0, 0, 0
 };
 
@@ -1451,6 +1453,24 @@
 {
 	if (buf[0] == 0x4d && buf[1] == 0x5a){
 		print(mime ? "application/x-msdownload\n" : "MSDOS executable\n");
+		return 1;
+	}
+	return 0;
+}
+
+int
+isicocur(void)
+{
+	if(buf[0] || buf[1] || buf[3] || buf[9])
+		return 0;
+	if(buf[4] == 0x00 && buf[5] == 0x00)
+		return 0;
+	switch(buf[2]){
+	case 1:
+		print(mime ? "image/x-icon\n" : "Microsoft icon file\n");
+		return 1;
+	case 2:
+		print(mime ? "image/x-icon\n" : "Microsoft cursor file\n");
 		return 1;
 	}
 	return 0;