Exemplo n.º 1
0
        // Returns null if the path is the root path.
        protected DirectoryItem GetDirectoryItemForPath(JungleDiskBucket bucket, string path)
        {
            DirectoryItem item = null;

            string[] pathParts = path.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
            if (pathParts.Length == 0)
            {
                return(null);
            }
            DirectoryContents contents = GetDirectoryListing(bucket, "");

            foreach (string pathPart in pathParts)
            {
                item = contents.ItemFor(pathPart);
                if (item.IsDirectory == false)
                {
                    return(item);
                }
                contents = GetDirectoryListingForMarker(bucket, item.Marker);
            }
            return(item);
        }
Exemplo n.º 2
0
        protected DirectoryContents GetDirectoryListingForMarker(JungleDiskBucket bucket, string parentMarker)
        {
            DirectoryContents output   = new DirectoryContents();
            string            resource = parentMarker + "/";

            SetBucket(bucket);
            string marker = ""; // Different kind of marker for continuing listings.

            List <string> markers          = new List <string>();
            Regex         filePointerRegex = new Regex("^([a-f0-9]{32})/file/(.+?)/(\\d+)/(\\d+)/(.*)$"); // Does not contain parent marker since it has been stripped as part of the prefix. ([a-f0-9]{32}|ROOT)/
            Regex         dirPointerRegex  = new Regex("^([a-f0-9]{32})/dir/(.+?)(/(.+))?$");

            S3Connection.ReceiveContentsDelegate markerDelegate = delegate(string key)
            {
                Match m;
                m = filePointerRegex.Match(key);
                if (m.Success)
                {
                    string selfMarker = m.Groups[1].Value;
                    string name       = FilterFileNameRead(m.Groups[2].Value, selfMarker);
                    int    size       = Convert.ToInt32(m.Groups[3].Value);
                    string attributes = m.Groups[5].Value;
                    output.Add(new DirectoryItem(name, selfMarker, parentMarker, false, size, attributes, resource + key, "FILES/" + selfMarker + "/0"));
                }
                m = dirPointerRegex.Match(key);
                if (m.Success)
                {
                    string selfMarker = m.Groups[1].Value;
                    string name       = FilterFileNameRead(m.Groups[2].Value, selfMarker);
                    string attributes = m.Groups[3].Success ? m.Groups[4].Value : ""; // this may not work
                    output.Add(new DirectoryItem(name, selfMarker, parentMarker, true, 0, attributes, resource + key, null));
                }
            };
            s3.GetObjectList(resource, ref marker, 0, null, markerDelegate, null);
            return(output);
        }
        protected DirectoryContents GetDirectoryListingForMarker(JungleDiskBucket bucket, string parentMarker)
        {
            DirectoryContents output = new DirectoryContents();
            string resource = parentMarker + "/";
            SetBucket(bucket);
            string marker = ""; // Different kind of marker for continuing listings.

            List<string> markers = new List<string>();
            Regex filePointerRegex = new Regex("^([a-f0-9]{32})/file/(.+?)/(\\d+)/(\\d+)/(.*)$"); // Does not contain parent marker since it has been stripped as part of the prefix. ([a-f0-9]{32}|ROOT)/
            Regex dirPointerRegex = new Regex("^([a-f0-9]{32})/dir/(.+?)(/(.+))?$");
            S3Connection.ReceiveContentsDelegate markerDelegate = delegate(string key)
            {
                Match m;
                m = filePointerRegex.Match(key);
                if (m.Success)
                {
                    string selfMarker = m.Groups[1].Value;
                    string name = FilterFileNameRead(m.Groups[2].Value, selfMarker);
                    int size = Convert.ToInt32(m.Groups[3].Value);
                    string attributes = m.Groups[5].Value;
                    output.Add(new DirectoryItem(name, selfMarker, parentMarker, false, size, attributes, resource + key, "FILES/" + selfMarker + "/0"));
                }
                m = dirPointerRegex.Match(key);
                if (m.Success)
                {
                    string selfMarker = m.Groups[1].Value;
                    string name = FilterFileNameRead(m.Groups[2].Value, selfMarker);
                    string attributes = m.Groups[3].Success ? m.Groups[4].Value : ""; // this may not work
                    output.Add(new DirectoryItem(name, selfMarker, parentMarker, true, 0, attributes, resource + key, null));
                }
            };
            s3.GetObjectList(resource, ref marker, 0, null, markerDelegate, null);
            return output;
        }