Exemplo n.º 1
0
			internal NodeVirtualFileInfo Create(VirtualFilePath Path, VirtualFileType CreateType, bool ErrorIfExists)
			{
				string FileName;
				var ParentDirectory = LocateParentNode(Path, out FileName);
				if (ParentDirectory.ContainsChild(FileName))
				{
					if (ErrorIfExists)
					{
						throw (new IOException("File Already Exists"));
					}
					else
					{
						return ParentDirectory.GetChild(FileName);
					}
				}
				else
				{
					return ParentDirectory.AddChild(FileName, CreateType);
				}
			}
            public static VirtualFileType Resolve(string request)
            {
                VirtualFileType type = new VirtualFileType();

                type.RequestPath = request;

                bool containsMlv = request.ToUpper().Contains(".MLV");
                bool containsRaw = request.ToUpper().Contains(".RAW");

                string ext = "";
                string storeDirExt = "";

                if (containsMlv)
                {
                    ext = ".MLV";
                    storeDirExt = ".MLD";
                }
                else
                {
                    ext = ".RAW";
                    storeDirExt = ".RAD";
                }

                type.LocalPath = GetLocalName(RootPath, request);
                type.MlvFilePath = GetMlvFileName(type.LocalPath);

                if(!File.Exists(type.MlvFilePath))
                {
                    type.Type = FileType.Direct;
                    type.LocalPath = GetLocalName(RootPath, request);
                    return type;
                }

                FileInfo mlvFileInfo = new FileInfo(type.MlvFilePath);
                type.MlvBaseName = mlvFileInfo.Name.ToUpper().Replace(ext, "");

                if (mlvFileInfo.Directory != null)
                {
                    type.MlvStoreDir = mlvFileInfo.Directory.FullName + Path.DirectorySeparatorChar + type.MlvBaseName + storeDirExt;
                }

                if (request.ToUpper().EndsWith(ext))
                {
                    type.LocalPath = "";
                    type.Type = FileType.PureVirtualDir;
                    return type;
                }
                else if (containsMlv || containsRaw)
                {
                    /* strip the requested file within that directory. e.g. 'M12-3456_<anything>' or 'foo.txt'  */
                    string requestedFile = type.LocalPath.Replace(type.MlvFilePath + Path.DirectorySeparatorChar, "");

                    /* is this not a M12-3456_<anything> filename? or is it a directory? */
                    if (!requestedFile.StartsWith(type.MlvBaseName) || requestedFile.Contains(Path.DirectorySeparatorChar))
                    {
                        type.Type = FileType.Redirected;
                        type.LocalPath = type.MlvStoreDir + Path.DirectorySeparatorChar + requestedFile;

                        return type;
                    }

                    string content = requestedFile.Replace(type.MlvBaseName, "").Trim('_');

                    /* save location in virtual directory in the "LocalPath" field */
                    type.LocalPath = type.MlvStoreDir + Path.DirectorySeparatorChar + requestedFile;

                    if (File.Exists(type.LocalPath))
                    {
                        type.Type = FileType.Redirected;
                        return type;
                    }

                    if (!MLVAccessor.FileExists(type.MlvFilePath, content))
                    {
                        type.Type = FileType.Redirected;
                        return type;
                    }

                    type.Type = FileType.PureVirtualFile;
                    type.MlvFileContent = content.ToUpper();
                    return type;
                }

                type.Type = FileType.Direct;
                type.LocalPath = GetLocalName(RootPath, request);
                return type;
            }
Exemplo n.º 3
0
			private NodeVirtualFileInfo AddChild(string Part, VirtualFileType Type)
			{
				var That = new NodeVirtualFileInfo(Part, Type, this);
				{
					this.Childs.Add(That);
					this.ChildsByName.Add(Part, That);
				}
				return That;
			}
Exemplo n.º 4
0
			public NodeVirtualFileInfo(string Name, VirtualFileType Type, NodeVirtualFileInfo Parent = null)
			{
				this.Name = Name;
				this.Type = Type;
				this.Parent = Parent;
			}