[gnome-boxes] Read & fill 1 line of unattended files at time
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Read & fill 1 line of unattended files at time
- Date: Fri, 16 Dec 2011 22:51:46 +0000 (UTC)
commit f17f7d1341b3d4d279561a0b45e5cc3cd33de0f2
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Dec 13 16:00:22 2011 +0200
Read & fill 1 line of unattended files at time
This is the only easy way to ensure we don't end-up getting a variable
split in separate reads and therefore not getting substituted.
https://bugzilla.gnome.org/show_bug.cgi?id=666086
src/unattended-installer.vala | 12 ++++++++----
src/win7-installer.vala | 2 ++
src/winxp-installer.vala | 2 ++
3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index cce915d..6b0d212 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -31,6 +31,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
protected string unattended_src_path;
protected string unattended_dest_name;
+ protected DataStreamNewlineType newline_type;
private bool created_floppy;
@@ -77,6 +78,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
floppy_path = get_pkgcache (os.short_id + "-unattended.img");
this.unattended_src_path = unattended_src_path;
this.unattended_dest_name = unattended_dest_name;
+ newline_type = DataStreamNewlineType.LF;
var time = TimeVal ();
var date = new DateTime.from_timeval_local (time);
@@ -288,12 +290,14 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
FileCreateFlags.REPLACE_DESTINATION,
Priority.DEFAULT,
cancellable);
- var buffer = new uint8[1024];
- size_t bytes_read;
- while ((bytes_read = yield input_stream.read_async (buffer, Priority.DEFAULT, cancellable)) > 0) {
- var str = ((string) buffer).substring (0, (long) bytes_read);
+ var data_stream = new DataInputStream (input_stream);
+ data_stream.newline_type = DataStreamNewlineType.ANY;
+ string? str;
+ while ((str = yield data_stream.read_line_async (Priority.DEFAULT, cancellable)) != null) {
str = fill_unattended_data (str);
+ str += (newline_type == DataStreamNewlineType.LF) ? "\n" : "\r\n";
+
yield output_stream.write_async (str.data, Priority.DEFAULT, cancellable);
}
yield output_stream.close_async (Priority.DEFAULT, cancellable);
diff --git a/src/win7-installer.vala b/src/win7-installer.vala
index 2cdf904..5398fa1 100644
--- a/src/win7-installer.vala
+++ b/src/win7-installer.vala
@@ -6,6 +6,8 @@ private class Boxes.Win7Installer: UnattendedInstaller {
var unattended_source = get_unattended_dir (media.os.short_id + ".xml");
base.copy (media, unattended_source, "Autounattend.xml");
+ newline_type = DataStreamNewlineType.CR_LF;
+
lang = lang.replace ("_", "-");
// Remove '.' and everything after it
lang = /\..*/i.replace (lang, -1, 0, "");
diff --git a/src/winxp-installer.vala b/src/winxp-installer.vala
index 64f4eba..5803994 100644
--- a/src/winxp-installer.vala
+++ b/src/winxp-installer.vala
@@ -22,6 +22,8 @@ private class Boxes.WinXPInstaller: UnattendedInstaller {
public WinXPInstaller.copy (InstallerMedia media) throws GLib.Error {
var unattended_source = get_unattended_dir (media.os.short_id + ".sif");
base.copy (media, unattended_source, "Winnt.sif");
+
+ newline_type = DataStreamNewlineType.CR_LF;
}
protected override void setup_ui () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]