@@ -41,9 +41,13 @@ private static void AddAssets(IDictionary<string, string> files, string tempPath
4141
4242 private static void AddFolder ( string tempPath , string folder , string destination )
4343 {
44- string [ ] files = Directory . GetFiles ( folder , "*" , SearchOption . AllDirectories ) ;
44+ string [ ] folders = Directory . GetDirectories ( folder , "*" , SearchOption . AllDirectories ) ;
45+ string [ ] files = Directory . GetFiles ( folder , "*" , SearchOption . AllDirectories ) ;
4546
46- foreach ( string filename in files )
47+ List < string > entries = new List < string > ( folders ) ;
48+ entries . AddRange ( files ) ;
49+
50+ foreach ( string filename in entries )
4751 {
4852 // metas will be copied with their asset
4953 if ( Path . GetExtension ( filename ) == ".meta" )
@@ -57,14 +61,17 @@ private static void AddFolder(string tempPath, string folder, string destination
5761
5862 private static void AddAsset ( string tempPath , string fromFile , string toPath )
5963 {
60- YamlDocument meta = GetMeta ( fromFile ) ?? GenerateMeta ( toPath ) ;
64+ YamlDocument meta = GetMeta ( fromFile ) ?? GenerateMeta ( fromFile , toPath ) ;
6165
6266 string guid = GetGuid ( meta ) ;
6367
6468 Directory . CreateDirectory ( Path . Combine ( tempPath , guid ) ) ;
6569
66- string assetPath = Path . Combine ( tempPath , guid , "asset" ) ;
67- File . Copy ( fromFile , assetPath ) ;
70+ if ( File . Exists ( fromFile ) )
71+ {
72+ string assetPath = Path . Combine ( tempPath , guid , "asset" ) ;
73+ File . Copy ( fromFile , assetPath ) ;
74+ }
6875
6976 string pathnamePath = Path . Combine ( tempPath , guid , "pathname" ) ;
7077 File . WriteAllText ( pathnamePath , toPath ) ;
@@ -98,15 +105,29 @@ private static string GetGuid(YamlDocument meta)
98105 return value . Value ;
99106 }
100107
101- private static YamlDocument GenerateMeta ( string filename )
108+ private static YamlDocument GenerateMeta ( string fromFile , string toFile )
102109 {
103- string guid = Utils . CreateGuid ( filename ) ;
110+ string guid = Utils . CreateGuid ( toFile ) ;
104111
105- return new YamlDocument ( new YamlMappingNode
112+ if ( Directory . Exists ( fromFile ) )
113+ {
114+ // this is a folder
115+ return new YamlDocument ( new YamlMappingNode
116+ {
117+ { "guid" , guid } ,
118+ { "fileFormatVersion" , "2" } ,
119+ { "folderAsset" , "yes" }
120+ } ) ;
121+ }
122+ else
123+ {
124+ // this is a file
125+ return new YamlDocument ( new YamlMappingNode
106126 {
107127 { "guid" , guid } ,
108128 { "fileFormatVersion" , "2" }
109129 } ) ;
130+ }
110131 }
111132
112133 private static YamlDocument GetMeta ( string filename )
0 commit comments