Skip to content

Commit d310c55

Browse files
committedApr 4, 2013
Initial commit
0 parents  commit d310c55

8 files changed

+446
-0
lines changed
 

‎.gitignore

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
11+
[Dd]ebug/
12+
[Rr]elease/
13+
x64/
14+
build/
15+
[Bb]in/
16+
[Oo]bj/
17+
18+
# MSTest test Results
19+
[Tt]est[Rr]esult*/
20+
[Bb]uild[Ll]og.*
21+
22+
*orig
23+
*_i.c
24+
*_p.c
25+
*.ilk
26+
*.meta
27+
*.obj
28+
*.pch
29+
*.pdb
30+
*.pgc
31+
*.pgd
32+
*.rsp
33+
*.sbr
34+
*.tlb
35+
*.tli
36+
*.tlh
37+
*.tmp
38+
*.tmp_proj
39+
*.log
40+
*.vspscc
41+
*.vssscc
42+
.builds
43+
*.pidb
44+
*.log
45+
*.scc
46+
47+
# Visual C++ cache files
48+
ipch/
49+
*.aps
50+
*.ncb
51+
*.opensdf
52+
*.sdf
53+
*.cachefile
54+
55+
# Visual Studio profiler
56+
*.psess
57+
*.vsp
58+
*.vspx
59+
60+
# Guidance Automation Toolkit
61+
*.gpState
62+
63+
# ReSharper is a .NET coding add-in
64+
_ReSharper*/
65+
*.[Rr]e[Ss]harper
66+
67+
# TeamCity is a build add-in
68+
_TeamCity*
69+
70+
# DotCover is a Code Coverage Tool
71+
*.dotCover
72+
73+
# NCrunch
74+
*.ncrunch*
75+
.*crunch*.local.xml
76+
77+
# Installshield output folder
78+
[Ee]xpress/
79+
80+
# DocProject is a documentation generator add-in
81+
DocProject/buildhelp/
82+
DocProject/Help/*.HxT
83+
DocProject/Help/*.HxC
84+
DocProject/Help/*.hhc
85+
DocProject/Help/*.hhk
86+
DocProject/Help/*.hhp
87+
DocProject/Help/Html2
88+
DocProject/Help/html
89+
90+
# Click-Once directory
91+
publish/
92+
93+
# Publish Web Output
94+
*.Publish.xml
95+
*.pubxml
96+
97+
# NuGet Packages Directory
98+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
99+
packages/
100+
101+
# Windows Azure Build Output
102+
csx
103+
*.build.csdef
104+
105+
# Windows Store app package directory
106+
AppPackages/
107+
108+
# Others
109+
sql/
110+
*.Cache
111+
ClientBin/
112+
[Ss]tyle[Cc]op.*
113+
~$*
114+
*~
115+
*.dbmdl
116+
*.[Pp]ublish.xml
117+
*.pfx
118+
*.publishsettings
119+
120+
# RIA/Silverlight projects
121+
Generated_Code/
122+
123+
# Backup & report files from converting an old project file to a newer
124+
# Visual Studio version. Backup files are not needed, because we have git ;-)
125+
_UpgradeReport_Files/
126+
Backup*/
127+
UpgradeLog*.XML
128+
UpgradeLog*.htm
129+
130+
# SQL Server files
131+
App_Data/*.mdf
132+
App_Data/*.ldf
133+
134+
# =========================
135+
# Windows detritus
136+
# =========================
137+
138+
# Windows image file caches
139+
Thumbs.db
140+
ehthumbs.db
141+
142+
# Folder config file
143+
Desktop.ini
144+
145+
# Recycle Bin used on file shares
146+
$RECYCLE.BIN/
147+
148+
# Mac crap
149+
.DS_Store

‎fileopenwrite.sln

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fileopenwrite", "fileopenwrite\fileopenwrite.vcxproj", "{A446517B-CFFE-422C-B19D-267E9747BA3A}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{A446517B-CFFE-422C-B19D-267E9747BA3A}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{A446517B-CFFE-422C-B19D-267E9747BA3A}.Debug|Win32.Build.0 = Debug|Win32
14+
{A446517B-CFFE-422C-B19D-267E9747BA3A}.Release|Win32.ActiveCfg = Release|Win32
15+
{A446517B-CFFE-422C-B19D-267E9747BA3A}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

‎fileopenwrite/fileopenwrite.cpp

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
2+
#include "stdafx.h"
3+
#include <windows.h>
4+
#include <tchar.h>
5+
#include <stdio.h>
6+
#include <strsafe.h>
7+
8+
void DisplayError(LPTSTR lpszFunction);
9+
10+
void __cdecl _tmain(int argc, TCHAR *argv[])
11+
{
12+
HANDLE hFile;
13+
char DataBuffer[] = "This is some test data to write to the file.\r\n";
14+
DWORD dwBytesToWrite = (DWORD)strlen (DataBuffer);
15+
DWORD dwBytesWritten = 0;
16+
BOOL bErrorFlag = FALSE;
17+
18+
printf("\n");
19+
if( argc != 3 )
20+
{
21+
printf("Usage Error:\tIncorrect number of arguments\n\n");
22+
_tprintf(TEXT("%s <file_name> <num_lines_to_print\n"), argv[0]);
23+
return;
24+
}
25+
26+
hFile = CreateFile(argv[1], // name of the write
27+
GENERIC_WRITE, // open for writing
28+
0, // do not share ##########This breaks tail.rb############
29+
NULL, // default security
30+
OPEN_ALWAYS, // create new file only
31+
FILE_ATTRIBUTE_NORMAL, // normal file
32+
NULL); // no attr. template
33+
34+
if (hFile == INVALID_HANDLE_VALUE)
35+
{
36+
DisplayError(TEXT("CreateFile"));
37+
_tprintf(TEXT("Terminal failure: Unable to open file \"%s\" for write.\n"), argv[1]);
38+
return;
39+
}
40+
41+
_tprintf(TEXT("Writing %d bytes to %s.\n"), dwBytesToWrite, argv[1]);
42+
int times = _tstoi(argv[2]);
43+
for(int i=0; i< times; i++){
44+
bErrorFlag = WriteFile(
45+
hFile, // open file handle
46+
DataBuffer, // start of data to write
47+
dwBytesToWrite, // number of bytes to write
48+
&dwBytesWritten, // number of bytes that were written
49+
NULL); // no overlapped structure
50+
}
51+
if (FALSE == bErrorFlag)
52+
{
53+
DisplayError(TEXT("WriteFile"));
54+
printf("Terminal failure: Unable to write to file.\n");
55+
}
56+
else
57+
{
58+
if (dwBytesWritten != dwBytesToWrite)
59+
{
60+
// This is an error because a synchronous write that results in
61+
// success (WriteFile returns TRUE) should write all data as
62+
// requested. This would not necessarily be the case for
63+
// asynchronous writes.
64+
printf("Error: dwBytesWritten != dwBytesToWrite\n");
65+
}
66+
else
67+
{
68+
_tprintf(TEXT("Wrote %d bytes to %s successfully.\n"), dwBytesWritten, argv[1]);
69+
}
70+
}
71+
72+
CloseHandle(hFile);
73+
}
74+
75+
void DisplayError(LPTSTR lpszFunction)
76+
// Routine Description:
77+
// Retrieve and output the system error message for the last-error code
78+
{
79+
LPVOID lpMsgBuf;
80+
LPVOID lpDisplayBuf;
81+
DWORD dw = GetLastError();
82+
83+
FormatMessage(
84+
FORMAT_MESSAGE_ALLOCATE_BUFFER |
85+
FORMAT_MESSAGE_FROM_SYSTEM |
86+
FORMAT_MESSAGE_IGNORE_INSERTS,
87+
NULL,
88+
dw,
89+
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
90+
(LPTSTR) &lpMsgBuf,
91+
0,
92+
NULL );
93+
94+
lpDisplayBuf =
95+
(LPVOID)LocalAlloc( LMEM_ZEROINIT,
96+
( lstrlen((LPCTSTR)lpMsgBuf)
97+
+ lstrlen((LPCTSTR)lpszFunction)
98+
+ 40) // account for format string
99+
* sizeof(TCHAR) );
100+
101+
if (FAILED( StringCchPrintf((LPTSTR)lpDisplayBuf,
102+
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
103+
TEXT("%s failed with error code %d as follows:\n%s"),
104+
lpszFunction,
105+
dw,
106+
lpMsgBuf)))
107+
{
108+
printf("FATAL ERROR: Unable to output error code.\n");
109+
}
110+
111+
_tprintf(TEXT("ERROR: %s\n"), (LPCTSTR)lpDisplayBuf);
112+
113+
LocalFree(lpMsgBuf);
114+
LocalFree(lpDisplayBuf);
115+
}

‎fileopenwrite/fileopenwrite.vcxproj

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{A446517B-CFFE-422C-B19D-267E9747BA3A}</ProjectGuid>
15+
<Keyword>Win32Proj</Keyword>
16+
<RootNamespace>fileopenwrite</RootNamespace>
17+
</PropertyGroup>
18+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
20+
<ConfigurationType>Application</ConfigurationType>
21+
<UseDebugLibraries>true</UseDebugLibraries>
22+
<PlatformToolset>v110</PlatformToolset>
23+
<CharacterSet>Unicode</CharacterSet>
24+
</PropertyGroup>
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
26+
<ConfigurationType>Application</ConfigurationType>
27+
<UseDebugLibraries>false</UseDebugLibraries>
28+
<PlatformToolset>v110</PlatformToolset>
29+
<WholeProgramOptimization>true</WholeProgramOptimization>
30+
<CharacterSet>Unicode</CharacterSet>
31+
</PropertyGroup>
32+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
33+
<ImportGroup Label="ExtensionSettings">
34+
</ImportGroup>
35+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
36+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
37+
</ImportGroup>
38+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
39+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
40+
</ImportGroup>
41+
<PropertyGroup Label="UserMacros" />
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
43+
<LinkIncremental>true</LinkIncremental>
44+
</PropertyGroup>
45+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
46+
<LinkIncremental>false</LinkIncremental>
47+
</PropertyGroup>
48+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
49+
<ClCompile>
50+
<PrecompiledHeader>Use</PrecompiledHeader>
51+
<WarningLevel>Level3</WarningLevel>
52+
<Optimization>Disabled</Optimization>
53+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
54+
<SDLCheck>true</SDLCheck>
55+
</ClCompile>
56+
<Link>
57+
<SubSystem>Console</SubSystem>
58+
<GenerateDebugInformation>true</GenerateDebugInformation>
59+
</Link>
60+
</ItemDefinitionGroup>
61+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
62+
<ClCompile>
63+
<WarningLevel>Level3</WarningLevel>
64+
<PrecompiledHeader>Use</PrecompiledHeader>
65+
<Optimization>MaxSpeed</Optimization>
66+
<FunctionLevelLinking>true</FunctionLevelLinking>
67+
<IntrinsicFunctions>true</IntrinsicFunctions>
68+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
69+
<SDLCheck>true</SDLCheck>
70+
</ClCompile>
71+
<Link>
72+
<SubSystem>Console</SubSystem>
73+
<GenerateDebugInformation>true</GenerateDebugInformation>
74+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
75+
<OptimizeReferences>true</OptimizeReferences>
76+
</Link>
77+
</ItemDefinitionGroup>
78+
<ItemGroup>
79+
<Text Include="ReadMe.txt" />
80+
</ItemGroup>
81+
<ItemGroup>
82+
<ClInclude Include="stdafx.h" />
83+
<ClInclude Include="targetver.h" />
84+
</ItemGroup>
85+
<ItemGroup>
86+
<ClCompile Include="fileopenwrite.cpp" />
87+
<ClCompile Include="stdafx.cpp">
88+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
89+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
90+
</ClCompile>
91+
</ItemGroup>
92+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
93+
<ImportGroup Label="ExtensionTargets">
94+
</ImportGroup>
95+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<Text Include="ReadMe.txt" />
19+
</ItemGroup>
20+
<ItemGroup>
21+
<ClInclude Include="stdafx.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
<ClInclude Include="targetver.h">
25+
<Filter>Header Files</Filter>
26+
</ClInclude>
27+
</ItemGroup>
28+
<ItemGroup>
29+
<ClCompile Include="stdafx.cpp">
30+
<Filter>Source Files</Filter>
31+
</ClCompile>
32+
<ClCompile Include="fileopenwrite.cpp">
33+
<Filter>Source Files</Filter>
34+
</ClCompile>
35+
</ItemGroup>
36+
</Project>

‎fileopenwrite/stdafx.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// stdafx.cpp : source file that includes just the standard includes
2+
// fileopenwrite.pch will be the pre-compiled header
3+
// stdafx.obj will contain the pre-compiled type information
4+
5+
#include "stdafx.h"
6+
7+
// TODO: reference any additional headers you need in STDAFX.H
8+
// and not in this file

‎fileopenwrite/stdafx.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// stdafx.h : include file for standard system include files,
2+
// or project specific include files that are used frequently, but
3+
// are changed infrequently
4+
//
5+
6+
#pragma once
7+
8+
#include "targetver.h"
9+
10+
#include <stdio.h>
11+
#include <tchar.h>
12+
13+
14+
15+
// TODO: reference additional headers your program requires here

‎fileopenwrite/targetver.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
// Including SDKDDKVer.h defines the highest available Windows platform.
4+
5+
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6+
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7+
8+
#include <SDKDDKVer.h>

0 commit comments

Comments
 (0)
Please sign in to comment.