public virtual id InitWithName(NSString name, NSString path)
{
id self = this;
NSColorList cl = null;
bool could_load = false;
_name = name;
if (path != null)
{
bool isDir = false;
// previously impl wrongly expected directory containing color file
// rather than color file; we support this for apps that rely on it
if ((NSFileManager.DefaultManager.FileExistsAtPath(path, ref isDir) == false) || isDir == true)
{
//NSLog(@"NSColorList -initWithName:fromFile: warning: excluding " @"filename from path (%@) is deprecated.", path);
_fullFileName = path.StringByAppendingPathComponent(name).StringByAppendingPathExtension(@"clr");
}
else
{
_fullFileName = path;
}
// Unarchive the color list
// TODO [Optm]: Rewrite to initialize directly without unarchiving
// in another object
try
{
//FIXME
//cl = (NSColorList) NSUnarchiver.UnarchiveObjectWithFile(_fullFileName);
}
catch (Exception ex)
{
cl = null;
}
if ((cl != null) && (cl.IsKindOfClass(NSColorList.Class)))
{
could_load = true;
_is_editable = NSFileManager.DefaultManager.IsWritableFileAtPath(_fullFileName);
_colorDictionary = NSMutableDictionary.DictionaryWithDictionary(cl._colorDictionary);
_orderedColorKeys = NSMutableArray.ArrayWithArray(cl._orderedColorKeys);
}
else if (NSFileManager.DefaultManager.FileExistsAtPath(path))
{
_colorDictionary = (NSMutableDictionary)NSMutableDictionary.Alloc().Init();
_orderedColorKeys = (NSMutableArray)NSMutableArray.Alloc().Init();
_is_editable = true;
if (_ReadTextColorFile(_fullFileName))
{
could_load = true;
_is_editable = NSFileManager.DefaultManager.IsWritableFileAtPath(_fullFileName);
}
else
{
_colorDictionary = null;
_orderedColorKeys = null;
}
}
}
if (could_load == false)
{
_fullFileName = null;
_colorDictionary = (NSMutableDictionary)NSMutableDictionary.Alloc().Init();
_orderedColorKeys = (NSMutableArray)NSMutableArray.Alloc().Init();
_is_editable = true;
}
return self;
}