Feature #1696

plugin/Zip/UnZip: interface simplification & a little optimisation

Added by Abdelghani Omari over 5 years ago. Updated over 5 years ago.

Status:ApprovedStart date:04/28/2017
Priority:NormalDue date:
Assignee:Miroslav Fidler% Done:

0%

Category:GeneralSpent time:-
Target version:Release 2017.2

Description

in the attached patch :
- update UnZip::ReadDir(): a file is added to the list only if all it's field are sets.
- add the possiblilty to load a file knowing it's path
- add search in the zip: Vector<String> UnZip::Search(String pattern)

currently, i have to do loop in each file in the zip in order to find a file knowing it's name.

        while(!(unzip.IsEof() || unzip.IsError())) {
            if(path == unzip.GetPath()))
                s = unzip.ReadFile();
            else
                unzip.SkipFile();
        }


it's usefull if we add this overload:
String UnZip::ReadFile(const char* path, Gate<int, int> progress = Null)
{
    for(int i = 0; i < file.GetCount(); i++)
    {
        if(file[i].path.IsEqual(path))
        {
            Seek(i);
            return ReadFile( progress );
        }
    }

    return String::GetVoid();
}


then the call will be :

    s = unzip.ReadFile(path);

zip.patch Magnifier (1.72 KB) Abdelghani Omari, 05/06/2017 04:50 PM

History

#1 Updated by Zbigniew Rebacz over 5 years ago

Why not?

for(int i = 0; i < file.GetCount(); i++) {}

for(const auto& f : file) {}

Just small tip :)

#2 Updated by Abdelghani Omari over 5 years ago

thanks for the tips, i will consider that in future
but here the index is used in Seek(i)

#3 Updated by Abdelghani Omari over 5 years ago

i think we shall add abbreviations for that "fa fca fab fdab" like fi, fj fib ..
fa = for(auto& a: @)
fcab = for(const auto& a:
@) {\r\n\t\r\n}

#4 Updated by Abdelghani Omari over 5 years ago

  • File zip.patch added
  • Subject changed from UnZip: allow reading file by path to plugin/Zip/UnZip: interface simplification & a little optimisation
  • Description updated (diff)
  • Priority changed from Low to Normal

#5 Updated by Abdelghani Omari over 5 years ago

  • File deleted (zip.patch)

#6 Updated by Abdelghani Omari over 5 years ago

#7 Updated by Miroslav Fidler over 5 years ago

  • Status changed from Patch ready to Approved

thanks

#8 Updated by Zbigniew Rebacz over 5 years ago

  • Target version set to Release 2017.2

Also available in: Atom PDF