首页 \ 问答 \ 如何在iOS上下载和解压缩文件(How to download & unzip files on iOS)

如何在iOS上下载和解压缩文件(How to download & unzip files on iOS)

我想为我的应用程序下载包含mp3的zip文件。 然后,我需要将其解压缩到一个永久目录中,该目录将包含要按需播放的mp3。 这是一个词汇应用程序,zip文件包含要提取的mp3。 zip文件大约5 MB。

更多问题:下载这些目录的好目录是什么? 解压缩怎么办? 此外,文件,或者更确切地说,它们所在的Web目录是受密码保护的,因此我需要提供名称和密码。

有人有任何一般指示吗? 特别是,我想知道如何提供用户名/密码,下载的最佳目录,如何解压缩文件以及如何下载。 任何代码示例将不胜感激。


I'd like to download a zip file containing mp3s for my app. Then, I will need to unzip it into a permanent directory, which will contain the mp3s to be played on demand. This is a vocabulary app and the zip file contains the mp3s to be extracted. The zip file as about 5 MB.

More questions: What's a good directory to download these to? How to do unzipping? Also, the files, or rather, the web directory they are in, is password protected, so I will need to provide the name and password.

Does anyone have any general pointers? In particular, I'd like to know how to provide the user name / password, the best directory to download to, how to unzip the file, and how to download. Any code samples would be greatly appreciated.


原文:https://stackoverflow.com/questions/11605545
更新时间:2023-08-02 18:08

最满意答案

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *args[]){
    FILE *finp, *keyFile, *fout;
    int i, ch;
    char key[2];

    if(argc == 4 && strcmp(args[1], "e") == 0){
        //Read two key character
        if ((keyFile = fopen(args[3], "r")) == NULL){
            printf("Could Not Open file %s\n", args[3]);
            exit(1);
        }
        if(1!=fscanf(keyFile, " %c", &key[0]) || 1!=fscanf(keyFile, " %c", &key[1])){
            printf("Could Not Read Key properly.\n");
            exit(1);
        }
        fclose(keyFile);

        if((finp = fopen(args[2], "rb")) == NULL){
            printf("Could Not Open file %s\n", args[2]);
            exit(1);
        }
        if((fout = fopen("out.dat", "wb")) == NULL){
            printf("Could Not Open file out.dat\n");
            exit(1);
        }

        i = 1;
        while((ch = fgetc(finp))!=EOF){
            fputc(ch ^ key[i], fout);
            i = !i;
        }
        fclose(fout);
        fclose(finp);
    } else {
        printf("SORRY!\n");
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *args[]){
    FILE *finp, *keyFile, *fout;
    int i, ch;
    char key[2];

    if(argc == 4 && strcmp(args[1], "e") == 0){
        //Read two key character
        if ((keyFile = fopen(args[3], "r")) == NULL){
            printf("Could Not Open file %s\n", args[3]);
            exit(1);
        }
        if(1!=fscanf(keyFile, " %c", &key[0]) || 1!=fscanf(keyFile, " %c", &key[1])){
            printf("Could Not Read Key properly.\n");
            exit(1);
        }
        fclose(keyFile);

        if((finp = fopen(args[2], "rb")) == NULL){
            printf("Could Not Open file %s\n", args[2]);
            exit(1);
        }
        if((fout = fopen("out.dat", "wb")) == NULL){
            printf("Could Not Open file out.dat\n");
            exit(1);
        }

        i = 1;
        while((ch = fgetc(finp))!=EOF){
            fputc(ch ^ key[i], fout);
            i = !i;
        }
        fclose(fout);
        fclose(finp);
    } else {
        printf("SORRY!\n");
    }

    return 0;
}

相关问答

更多
  • 在某处可能有一条空行(当它在最后时很难发现),所以csv模块发出一个空行。 有时通过不正确地写入csv文件来生成空行(忘记为python 2设置二进制模式,忘记为python 3添加newline="" ) 要计算非空行,只需忘记你的for循环,然后执行: question_count = sum(1 for line in reader if line) 请注意,使用此方法,您必须回滚文件以获取内容。 另一种方法是首先将行存储在列表中: line = list(line) 。 (上面的代码仍然适用) t ...
  • 你不是在写一个文本文件。 加密数据实际上是随机位,并且您的main将encrypt的返回值直接传递给Files.write(Path,byte[]) ,后者将其写为二进制。 当您使用FileReader重新读取它时,它会使用您未识别的平台的默认编码,有时也会使用您的用户环境,这可能会或可能不会破坏某些字节; 使用readLine()可能会丢弃部分数据,并使用getBytes("UTF-8")对其进行编码,因为它从来没有有效的字符开始时大约99.6%肯定会破坏任何剩余的数据。 因此,您传递给decrypt值完 ...
  • 我们可以使用dput()函数。 dput(hcity.D2 “的test.txt”) We can use dput() function. dput(hcity.D2,"test.txt")
  • #include #include #include int main(int argc, char *args[]){ FILE *finp, *keyFile, *fout; int i, ch; char key[2]; if(argc == 4 && strcmp(args[1], "e") == 0){ //Read two key character if ((ke ...
  • 作为回顾,我发现了两个可能解决问题的方法。 第一个也是不太理想的是只删除代码的启动行。 第二个是打破问题行的函数调用,这样: $("#workNews").text(lines[i++]).hide().fadeIn(500).delay(4000).fadeOut(500); 成为这个: $("#workNews").text(lines[i++]); $("#workNews").hide(); $("#workNews").fadeIn(500); $("#workNews").delay(4000 ...
  • 如果你查看完整的回溯,你会发现错误就在这里 ft.write((ord(ch))^65535) write需要一个字符缓冲区对象(例如字符串),但是你传递一个int 。 但是你不能只使用str()因为它会将字节转换为ASCII。 要将其写为二进制数据,请使用bytearray() 。 ft.write(bytearray([ord(ch)^0xff])) If you look at the full traceback, you will see that the error is right her ...
  • 所以,通过对这个问题的一些理解,我相信你真的在寻找一种混淆形式? 正如评论中所提到的,最简单的方法可能是一种密码形式。 考虑移位密码的这个示例实现: 共同 int shift = 11; 写作 // Get the data to be wrote to file. String data = ... // cipher the data. char[] chars = data.toCharArray(); for (int i = 0; i < chars.length; ++i) { ch ...
  • 这与您的代码并不完全相关,但尝试将具有固定宽度块大小的块密码转换为可以在流上工作的块密码并不是加密安全的,只需将输入拆分为块并加密即可他们每个人。 如果你这样做,你基本上是在做一个美化的单字母替换密码,其中每个“字符”是一个块宽。 这允许攻击者恢复输入结构的某些部分,这会破坏您通常从这些加密原语获得的保证。 作为一个例子,请参阅维基百科关于这种特定加密模式的讨论,看看它如何加密Linux企鹅的Tux。 加密图像可以立即让您查看输入的结构。 如果你想使用像ElGamal这样的分组密码来加密文本流,你应该使用更 ...
  • 使用list comprehension将键转换为数字并删除值: keys = [int(key) for key in keys] values = [value.strip() for value in values] 然后按照您的代码。 Use list comprehension to convert keys to numbers and strip the values: keys = [int(key) for key in keys] values = [value.strip() for ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)