์๋์ฐ์์ ์์ถํ zipํ์ผ, linux์์ ํ๊ธ์ด ๊นจ์ง ๋
์๋์ฐ์์ ํ๊ธ ์ด๋ฆ์ผ๋ก ๋ ํ์ผ์ด๋ ํด๋๋ฅผ zip์ผ๋ก ์์ถํ๊ณ , ๋ฆฌ๋ ์ค์์ ๊ฐ์ ธ์์ ์์ถ์ ํธ๋ ๊ฒฝ์ฐ, ํ๊ธ์ด ๊นจ์ง ๋๊ฐ ์์ต๋๋ค.
์ด์ ๋ ์๋์ฐ์์ ํ๊ธ ์ธ์ฝ๋ฉ์ ๊ธฐ๋ณธ์ผ๋ก MS949๋ฅผ ์ฌ์ฉํ๊ณ ์๋๋ฐ, ๋ฆฌ๋ ์ค์์ ์ธ์ฝ๋ฉ์ด UTF-8๋ก ์ค์ ๋ ๊ฒฝ์ฐ์ ๋๋ค.
๋ฆฌ๋ ์ค์ ์ธ์ฝ๋ฉ ๋ฐฉ์์ euckr๋ก ์ค์ ํ๋ ๊ฒฝ์ฐ, ํธํ์ด ๋ ์๋ ์์ง๋ง, ๋ค๊ตญ์ด์ฒ๋ฆฌ ๋ฌธ์ ๊ฐ ์๊ธฐ๋ฏ๋ก, UTF-8 ๋ฐฉ์์ ๊ถ์ฅํฉ๋๋ค.
๋ฆฌ๋ ์ค์ ์ธ์ฝ๋ฉ ๋ฐฉ์์ ๋จผ์ ํ์ธํฉ๋๋ค.
$ echo $LANG
์ ํ๋ฉด ํ์ฌ ์ธ์ฝ๋ฉ ์ ๋ณด๋ฅผ ์ ์ ์์ต๋๋ค. ๋ง์ฝ UTF-8์ด ์๋ ๊ฒฝ์ฐ, .bash_profile ์ด๋ ๊ธฐํ ํ๊ฒฝ์ค์ ํ์ผ์
export LANG=ko_KR.UTF-8
๋ฅผ ๋ฃ์ด์ค๋๋ค.
์์ถ์ ํ๊ธฐ ์ํด ์ฌ์ฉํ ์์ค๋ 7-zip.org ์ linux ๋ฒ์ ์ธ http://sourceforge.net/projects/p7zip/ ๋ฅผ ์ฌ์ฉํ์ต๋๋ค.
์ฐ์ ์ต์ ์์ค์ธ 9.20.1 ๋ฅผ ๋ค์ด๋ฐ์ต๋๋ค.
http://sourceforge.net/projects/p7zip/files/latest/download?source=files
$ tar xvjf p7zip_9.20.1_src_all.tar.bz2 cd p7zip_9.20.1 make
ํ๊ฒ ๋๋ฉด, ๊ธฐ๋ณธ์ ์ผ๋ก bin/7za ๋ผ๋ ํ์ผ์ด ์๊น๋๋ค. ํ์ง๋ง, ์ด ํ์ผ์ ๊ทธ๋๋ก ์ฌ์ฉํ๊ฒ ๋๋ฉด, ํ๊ธ์ด ๊นจ์ ธ๋ณด์ด๊ฒ ๋ฉ๋๋ค.
ํ๊ธ์ ๊นจ์ง์ง ์๊ฒ ํ๋ ค๋ฉด ์์ค ํ์ผ ํ๋์ ์์ ์ด ํ์ํฉ๋๋ค.
$ vi p7zip_9.20.1/CPP/Common/StringConvert.cpp
#include "StdAfx.h" #include <stdlib.h>
์๋์
#include <iconv.h> #include <errno.h>
๋ฅผ ์ถ๊ฐ
#ifdef LOCALE_IS_UTF8
์๋ก..
#define LOCALE_IS_UTF8 static int iconv_wrapper(const char* p_from, const char* p_to, const char* p_src, char* p_dst) { if (p_src == NULL || p_dst == NULL) { return -210001; } size_t srclen; size_t dstlen; size_t inleftsize, outleftsize; size_t res; iconv_t cd = (iconv_t)-1; char* inptr = (char*)p_src; char* outptr = p_dst; cd = iconv_open(p_to, p_from); if (cd == (iconv_t)-1) { return -140005; } inleftsize = srclen = strlen(p_src); outleftsize = dstlen = inleftsize * 4; while (1) { res = iconv(cd, &inptr, &inleftsize, &outptr, &outleftsize); if (res == (size_t)-1) { if (errno == EILSEQ) { inptr++; inleftsize--; } else if (errno == EINVAL) { if (inleftsize <=2) { *outptr = '?'; outleftsize--; break; } } *outptr = '?'; outptr++; outleftsize--; inptr++; inleftsize--; } else break; } iconv_close(cd); if (dstlen-outleftsize <= 0) { return -210002; } p_dst[dstlen-outleftsize] = '\0'; return 0; }
์๋ ํจ์๋ฅผ ์ฐพ์ต๋๋ค. (๊ฐ์ ์ด๋ฆ์ ํจ์๊ฐ ๋ง์ผ๋, ํจ์ ์์ ๋ด์ฉ์ ํ์ธํ์ธ์.
UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) { if ((global_use_utf16_conversion) && (!srcString.IsEmpty())) { UString resultString; bool bret = ConvertUTF8ToUnicode(srcString,resultString); if (bret) return resultString; }
์๋์ ๊ฐ์ด ๋ณ๊ฒฝํฉ๋๋ค.
UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) { if ((global_use_utf16_conversion) && (!srcString.IsEmpty())) { AString astr = srcString; int len = astr.Length(); char* p_a_str = astr.GetBuffer(len+1); char buf_utf8[65536] = {0,}; iconv_wrapper("UTF-8", "UTF-8", p_a_str, buf_utf8); if (strcmp(p_a_str, buf_utf8) != 0) iconv_wrapper("CP949", "UTF-8", p_a_str, buf_utf8); astr = buf_utf8; UString resultString; bool bret = ConvertUTF8ToUnicode(astr,resultString); if (bret) return resultString; }
๋ค์ make ๋ฅผ ํ๊ณ bin/7za ๋ฅผ ์ฌ์ฉํ๋ฉด ํ๊ธ์ด ๊นจ์ง์ง ์์ต๋๋ค~ ^_^
ํ ์คํธ ํ๊ฒฝ: CentOS 6.3 64bit, Ubuntu 12.10
๊ฐ๊ฐ์ ํ๊ฒฝ์์ ์ปดํ์ผํ ๋ฐ์ด๋๋ฆฌ๋ ์๋ ๋งํฌ์์ ๋ฐ์ ์ ์์ต๋๋ค.
https://dl.dropbox.com/u/2660823/7za_cent6_64.zip
https://dl.dropbox.com/u/2660823/7za_ubuntu1210.zip
์ฐธ๊ณ : 7za ์ฌ์ฉ๋ฐฉ๋ฒ
7za l test.zip : ๋ฆฌ์คํธ
7za x test.zip : ์์ถํ๊ธฐ
7za a test.zip file1 file2 dir1 dir2 : ์์ถํ๊ธฐ
์ต์
-ba ํค๋ disable
-bd ํผ์ผํธ disable
-aoa ๋ฎ์ด์ฐ๊ธฐ
-aou ์์ด๋ฆ
-aos Skip
-oDIR output directory
-i@LISTFILE ํ์ผ๋ชฉ๋ก














