Пример #1
0
        public override Stream OpenInputFileStream(string path)
        {
            Stream st = null;

            StreamResourceInfo sr = Application.GetResourceStream(new Uri(CFilePath.removeFirstSlash(path), UriKind.Relative));
            if (sr != null)
                st = sr.Stream;

            if (st == null)
            {
                try
                {
                    CRhoFile file = new CRhoFile();
                    file.open(path, CRhoFile.EOpenModes.OpenReadOnly);
                    st = file.getStream();
                }
                catch (Exception exc)
                {
                    throw new System.IO.FileNotFoundException();
                }
            }

            if (st == null)
                throw new System.IO.FileNotFoundException();

            return st;
        }
Пример #2
0
	    public NetResponse pullFile( String strUrl, String strFileName, IRhoSession oSession, Hashtable<String, String> headers )
	    {
		    NetResponse resp = null;
            m_isPullFile = true;

		    m_bCancel = false;
    	
		    try{

	            if (!strFileName.startsWith("file:")) { 
            	    try{
	            	    strFileName = CFilePath.join(CRhodesApp.getRhoRootPath(), strFileName);
            	    } catch (IOException e) { 
                 	    LOG.ERROR("getDirPath failed.", e);
                    }              	
	            }

                m_pulledFile = RhoClassFactory.createFile();
                m_pulledFile.open(strFileName, CRhoFile.EOpenModes.OpenForReadWrite);
                m_pulledFile.setPosTo(m_pulledFile.size());
			
			    do{
                    resp = doRequest("GET", strUrl, null, oSession, headers, m_pulledFile.size());
			    }while( !m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0);
			
		    }finally{
                if (m_pulledFile != null)
			    {
                    try { m_pulledFile.close(); }
                    catch (IOException e)
                    {
                        LOG.ERROR("file closing failed.", e);
                    }
                    m_pulledFile = null;
			    }
		    }
		
		    copyHashtable(m_OutHeaders, headers);

            m_isPullFile = false;
            m_nCurDownloadSize = 0;
            return resp != null && !m_bCancel ? resp : makeResponse("", Convert.ToInt32(HttpStatusCode.InternalServerError));
	    }
        public override Stream OpenInputFileStream(string path, FileMode mode, FileAccess access, FileShare share)
        {
            //TODO: OpenInputFileStream with params

            Stream st = null;
            if (access == FileAccess.Read)
                return OpenInputFileStream(path);
            else
            {
                CRhoFile file = new CRhoFile();
                file.open(path, CRhoFile.EOpenModes.OpenForReadWrite);
                st = file.getStream();
            }

            if (st == null)
                throw new System.IO.FileNotFoundException();

            return st;
        }
        public override Stream OpenInputFileStream(string path, FileMode mode, FileAccess access, FileShare share)
        {
            //TODO: OpenInputFileStream with params

            Stream st = null;
            if (access == FileAccess.Read)
            {
                st = OpenInputFileStream(path);
                if (st == null)
                {
                    CRhoFile file = new CRhoFile();
                    file.open(path, CRhoFile.EOpenModes.OpenReadOnly);
                    st = file.getStream();
                }

            }
            else
            {
                CRhoFile file = new CRhoFile();
                file.open(path, CRhoFile.EOpenModes.OpenForReadWrite);
                st = file.getStream();
            }

            return st;
        }