diff src/org/tmatesoft/hg/internal/FNCacheFile.java @ 667:fba85bc1dfb8

Refactoring: move all encoding/decoding operations into single place, EncodingHelper
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 11 Jul 2013 17:54:08 +0200
parents ae2d439fbed3
children
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/FNCacheFile.java	Wed Jul 10 20:22:07 2013 +0200
+++ b/src/org/tmatesoft/hg/internal/FNCacheFile.java	Thu Jul 11 17:54:08 2013 +0200
@@ -24,7 +24,6 @@
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.channels.FileChannel;
-import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -83,7 +82,7 @@
 		}
 		File f = repo.getRepositoryFile(FNCache);
 		f.getParentFile().mkdirs();
-		final Charset filenameEncoding = repo.getFilenameEncoding();
+		final EncodingHelper fnEncoder = repo.buildFileNameEncodingHelper();
 		ArrayList<CharBuffer> added = new ArrayList<CharBuffer>();
 		for (Path p : addedDotI) {
 			added.add(CharBuffer.wrap(pathHelper.rewrite(p)));
@@ -105,7 +104,7 @@
 			FileChannel fncacheFile = fos.getChannel();
 			ByteBuffer lf = ByteBuffer.wrap(new byte[] { 0x0A });
 			for (CharBuffer b : added) {
-				fncacheFile.write(filenameEncoding.encode(b));
+				fncacheFile.write(fnEncoder.toFNCache(b));
 				fncacheFile.write(lf);
 				lf.rewind();
 			}