如何在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
最满意答案
#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; }
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
在某处可能有一条空行(当它在最后时很难发现),所以csv模块发出一个空行。 有时通过不正确地写入csv文件来生成空行(忘记为python 2设置二进制模式,忘记为python 3添加newline="" ) 要计算非空行,只需忘记你的for循环,然后执行: question_count = sum(1 for line in reader if line) 请注意,使用此方法,您必须回滚文件以获取内容。 另一种方法是首先将行存储在列表中: line = list(line) 。 (上面的代码仍然适用) t ...
-
使用AES加密/解密并将信息存储在文本文件中(Encrypting/Decrypting with AES and storing information in text file)[2023-04-20]
你不是在写一个文本文件。 加密数据实际上是随机位,并且您的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 ...
-
加密文件的困惑(Confusion in encryption of a file)[2020-01-27]
如果你查看完整的回溯,你会发现错误就在这里 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 ... -
文本文件的字节加密(Byte encryption for text file)[2024-01-26]
所以,通过对这个问题的一些理解,我相信你真的在寻找一种混淆形式? 正如评论中所提到的,最简单的方法可能是一种密码形式。 考虑移位密码的这个示例实现: 共同 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 ...