Granados.SSH2.SSH2UserAuthKey.WriteKeyFileBlock C# (CSharp) Method

WriteKeyFileBlock() private static method

private static WriteKeyFileBlock ( StreamWriter sw, string data, bool escape_needed ) : void
sw System.IO.StreamWriter
data string
escape_needed bool
return void
        private static void WriteKeyFileBlock(StreamWriter sw, string data, bool escape_needed)
        {
            char[] d = data.ToCharArray();
            int cursor = 0;
            const int maxlen = 70;
            while (cursor < d.Length) {
                if (maxlen >= d.Length - cursor)
                    sw.WriteLine(d, cursor, d.Length - cursor);
                else {
                    if (escape_needed) {
                        sw.Write(d, cursor, maxlen - 1);
                        sw.WriteLine('\\');
                        cursor--;
                    }
                    else
                        sw.WriteLine(d, cursor, maxlen);
                }

                cursor += maxlen;
            }
        }