public override INode DoCreate(bool createParent)
        {
            if (!createParent)
            {
                if (!this.Address.IsRoot && !ParentDirectory.Exists)
                {
                    throw new IOException();
                }

                // Mono crashes with ** ERROR **: file object.c: line 1301 (mono_object_get_virtual_method): assertion failed: (res)
                // DictionaryBasedNodeAttributes attribs = this.Attributes;

                var attribs = ((DictionaryBasedNodeAttributes)base.Attributes);

                using (attribs.GetAutoLock().Lock())
                {
                    attribs.SetValue <bool>("Exists", true);
                }

                return(this);
            }

            if (!this.Address.IsRoot && !ParentDirectory.Exists)
            {
                ParentDirectory.Create(true);
            }

            this.Attributes.SetValue <bool>("Exists", true);

            ((ImaginaryDirectory)ParentDirectory).Add(this);

            return(this);
        }
Exemple #2
0
        /// <summary>
        /// Create the file if it does not already exist.
        /// </summary>
        public void Create()
        {
            if (!Exists)
            {
                // This will recursively create parent directory if any of them not existed.
                ParentDirectory.Create();

                System.IO.File.Create(Path).Dispose();
            }
        }