forked from onevcat/XUPorter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXCPlist.cs
59 lines (50 loc) · 1.25 KB
/
XCPlist.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
namespace UnityEditor.XCodeEditor
{
public partial class XCPlist : System.IDisposable
{
private string filePath;
List<string> contents = new List<string>();
public XCPlist(string fPath)
{
filePath = Path.Combine( fPath, "info.plist" );
if( !System.IO.File.Exists( filePath ) ) {
Debug.LogError( filePath +"路径下文件不存在" );
return;
}
FileInfo projectFileInfo = new FileInfo( filePath );
StreamReader sr = projectFileInfo.OpenText();
while (sr.Peek() >= 0)
{
contents.Add(sr.ReadLine());
}
sr.Close();
}
public void AddKey(string key)
{
if(contents.Count < 2)
return;
contents.Insert(contents.Count - 2,key);
}
public void ReplaceKey(string key,string replace){
for(int i = 0;i < contents.Count;i++){
if(contents[i].IndexOf(key) != -1){
contents[i] = contents[i].Replace(key,replace);
}
}
}
public void Save()
{
StreamWriter saveFile = File.CreateText(filePath);
foreach(string line in contents)
saveFile.WriteLine(line);
saveFile.Close();
}
public void Dispose()
{
}
}
}